Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nuxt-modules/i18n
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.11.0
Choose a base ref
...
head repository: nuxt-modules/i18n
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.11.1
Choose a head ref
  • 14 commits
  • 8 files changed
  • 3 contributors

Commits on Apr 30, 2020

  1. chore: adjust stale bot settings

    rchl committed Apr 30, 2020
    Copy the full SHA
    3b77fda View commit details

Commits on May 1, 2020

  1. chore(deps): update all non-major dependencies (#686)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 1, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6c9bbc4 View commit details

Commits on May 4, 2020

  1. chore(deps): lock file maintenance (#696)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 4, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    984c430 View commit details

Commits on May 9, 2020

  1. Copy the full SHA
    f646456 View commit details
  2. Copy the full SHA
    624519c View commit details
  3. Copy the full SHA
    5d2df51 View commit details
  4. chore(github) update template

    rchl committed May 9, 2020
    Copy the full SHA
    715e793 View commit details
  5. chore(github) update template

    rchl committed May 9, 2020
    Copy the full SHA
    138352d View commit details

Commits on May 10, 2020

  1. fix: NavigationDuplicated error on loading 404 page in SPA (#705)

    Also fixed an issue where would not respect query params when redirecting.
    
    Resolves #702
    rchl authored May 10, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6bd80da View commit details
  2. chore(deps): update dependency eslint to v7 (#701)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 10, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    51fc61b View commit details
  3. Copy the full SHA
    bb0b911 View commit details
  4. chore(deps): update dependency jest to v26 (#698)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 10, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5f86712 View commit details
  5. chore(deps): update all non-major dependencies (#695)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 10, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b59491d View commit details
  6. chore: release 6.11.1

    rchl committed May 10, 2020
    Copy the full SHA
    833f2f3 View commit details
Showing with 1,534 additions and 1,675 deletions.
  1. +4 −4 .eslintrc.js
  2. +17 −0 .github/ISSUE_TEMPLATE/bug_report.md
  3. +2 −1 .github/stale.yml
  4. +7 −0 CHANGELOG.md
  5. +12 −11 package.json
  6. +13 −12 src/templates/plugin.main.js
  7. +44 −1 test/browser.test.js
  8. +1,435 −1,646 yarn.lock
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
root: true,
extends: [
'@nuxtjs/eslint-config-typescript',
'@nuxtjs/eslint-config-typescript'
],
plugins: [
'jest',
'jest'
],
rules: {
'arrow-parens': 'off',
'vue/html-closing-bracket-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/singleline-html-element-content-newline': 'off',
},
'vue/singleline-html-element-content-newline': 'off'
}
}
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,23 @@ assignees: ''
nuxt-i18n: <!-- ex: 5.9.0 -->
nuxt: <!-- ex: 2.0.0 -->

### Nuxt configuration
#### [mode](https://nuxtjs.org/api/configuration-mode): <!--universal is the default -->
- [ ] universal
- [ ] spa

### Nuxt-i18n configuration
<!--
If relevant, please include the configuration you are using for this module.
For example:
```
i18n: {
strategy: 'prefix',
...
}
```
-->

### Reproduction Link
<!-- A minimal test case on https://template.nuxtjs.org/ or GitHub reprository that can reproduce the bug. -->

3 changes: 2 additions & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
@@ -6,8 +6,9 @@ daysUntilClose: 7
exemptLabels:
- pinned
- security
exemptAssignees: true
# Label to use when marking an issue as stale
staleLabel: wontfix
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### [6.11.1](https://github.com/nuxt-community/nuxt-i18n/compare/v6.11.0...v6.11.1) (2020-05-10)


### Bug Fixes

* NavigationDuplicated error on loading 404 page in SPA ([#705](https://github.com/nuxt-community/nuxt-i18n/issues/705)) ([6bd80da](https://github.com/nuxt-community/nuxt-i18n/commit/6bd80da4ee21918abb551629720723dc82d69fc0)), closes [#702](https://github.com/nuxt-community/nuxt-i18n/issues/702)

## [6.11.0](https://github.com/nuxt-community/nuxt-i18n/compare/v6.10.1...v6.11.0) (2020-04-30)


23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-i18n",
"version": "6.11.0",
"version": "6.11.1",
"description": "i18n for Nuxt",
"license": "MIT",
"contributors": [
@@ -54,7 +54,8 @@
},
"github": {
"release": true,
"releaseName": "${version}"
"releaseName": "${version}",
"releaseNotes": "echo \"${changelog}\" | sed 1,2d"
},
"plugins": {
"@release-it/conventional-changelog": {
@@ -89,27 +90,27 @@
"vue-i18n": "^8.17.3"
},
"devDependencies": {
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.5",
"@babel/runtime": "7.9.2",
"@nuxt/types": "0.7.4",
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"@babel/runtime": "7.9.6",
"@nuxt/types": "0.7.5",
"@nuxtjs/eslint-config-typescript": "1.0.2",
"@nuxtjs/module-test-utils": "1.6.1",
"@release-it/conventional-changelog": "1.1.3",
"@release-it/conventional-changelog": "1.1.4",
"@types/jest": "25.2.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"chromedriver": "81.0.0",
"codecov": "3.6.5",
"core-js": "3.6.5",
"eslint": "6.8.0",
"eslint": "7.0.0",
"geckodriver": "1.19.1",
"jest": "25.4.0",
"jest": "26.0.1",
"jsdom": "16.2.2",
"messageformat": "2.3.0",
"nuxt": "2.12.2",
"puppeteer-core": "3.0.1",
"release-it": "13.5.5",
"puppeteer-core": "3.0.4",
"release-it": "13.5.8",
"selenium-webdriver": "4.0.0-alpha.7",
"tib": "0.7.4",
"typescript": "3.8.3",
25 changes: 13 additions & 12 deletions src/templates/plugin.main.js
Original file line number Diff line number Diff line change
@@ -85,7 +85,9 @@ export default async (context) => {

await syncVuex(store, newLocale, app.i18n.getLocaleMessage(newLocale), { vuex })

const redirectPath = getRedirectPathForLocale(newLocale)
// Must retrieve from context as it might have changed since plugin initialization.
const { route } = context
const redirectPath = getRedirectPathForLocale(route, newLocale)

if (initialSetup) {
// Redirect will be delayed until middleware runs as redirecting from plugin does not
@@ -100,25 +102,24 @@ export default async (context) => {
}
}

const getRedirectPathForLocale = locale => {
const getRedirectPathForLocale = (route, locale) => {
if (!locale || app.i18n.differentDomains || strategy === STRATEGIES.NO_PREFIX) {
return
return ''
}

// Must retrieve from context as it might have changed since plugin initialization.
const { route } = context
const routeLocale = getLocaleFromRoute(route)

if (routeLocale === locale) {
return
if (getLocaleFromRoute(route) === locale) {
return ''
}

// At this point we are left with route that either no or different locale.
// At this point we are left with route that either has no or different locale.
let redirectPath = app.switchLocalePath(locale)

if (!redirectPath) {
// Could be a 404 route in which case we should attemp to find matching route for given locale.
redirectPath = app.localePath(route.path, locale)
// Current route could be 404 in which case attempt to find matching route for given locale.
redirectPath = app.localePath(route.fullPath, locale)
if (redirectPath === route.fullPath) {
return ''
}
}

return redirectPath
45 changes: 44 additions & 1 deletion test/browser.test.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@ async function createDefaultBrowser () {
staticServer: false,
extendPage (page) {
return {
navigate: createNavigator(page)
navigate: createNavigator(page),
getRouteFullPath () {
return page.runScript(() => window.$nuxt.$route.fullPath)
}
}
}
})
@@ -244,6 +247,46 @@ describe(`${browserString} (no fallbackLocale, browser language not supported)`,
})
})

describe(`${browserString} (SPA)`, () => {
let nuxt
let browser
let page

beforeAll(async () => {
const overrides = {
mode: 'spa'
}

nuxt = (await setup(loadConfig(__dirname, 'basic', overrides, { merge: true }))).nuxt
browser = await createDefaultBrowser()
})

afterAll(async () => {
if (browser) {
await browser.close()
}

await nuxt.close()
})

test('renders existing page', async () => {
page = await browser.page(url('/'))
expect(await page.getText('body')).toContain('locale: en')
})

test('renders 404 page', async () => {
page = await browser.page(url('/nopage'))
expect(await page.getText('body')).toContain('page could not be found')
})

test('preserves the URL on 404 page', async () => {
const path = '/nopage?a#h'
page = await browser.page(url(path))
expect(await page.getText('body')).toContain('page could not be found')
expect(await page.getRouteFullPath()).toBe(path)
})
})

describe(`${browserString} (SPA with router in hash mode)`, () => {
let nuxt
let browser
3,081 changes: 1,435 additions & 1,646 deletions yarn.lock

Large diffs are not rendered by default.