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.10.1
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.0
Choose a head ref
  • 8 commits
  • 22 files changed
  • 4 contributors

Commits on Apr 23, 2020

  1. chore(structure): move plugin files into templates

    So that local editor can properly resolve imports.
    rchl committed Apr 23, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    suzuki-shunsuke Shunsuke Suzuki
    Copy the full SHA
    ce13a23 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e6dfe76 View commit details

Commits on Apr 24, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    08da4eb View commit details

Commits on Apr 25, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bea56a9 View commit details

Commits on Apr 30, 2020

  1. fix: redirect from 404 to defaultLocale if there is matching route

    Changes the `setLocale` logic to, in case current route is 404, to
    try to find a matching one for current locale. This is for situations
    when using `prefix` strategy where the root (`/`) route doesn't exist.
    We will try to find and redirect to prefixed route matching resolved locale.
    
    Also worked around Nuxt issue (nuxt/nuxt#4491 )
    with `redirect` not working when called from a plugin in SPA mode.
    Required for the above fix above to be functional in SPA.
    
    Resolves #677
    Resolves #491
    rchl committed Apr 30, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e99978d View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    15ada7d View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f688177 View commit details
  4. chore: release 6.11.0

    rchl committed Apr 30, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    0c0f75e View commit details
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ contact_links:
about: Consider asking questions about the module here.
- name: nuxt-i18n documentation
url: https://nuxt-community.github.io/nuxt-i18n/
about: Check our documenation before reporting issues or questions.
about: Check our documentation before reporting issues or questions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [6.11.0](https://github.com/nuxt-community/nuxt-i18n/compare/v6.10.1...v6.11.0) (2020-04-30)


### Features

* **docs:** enable indexed search results in documentation ([#687](https://github.com/nuxt-community/nuxt-i18n/issues/687)) ([bea56a9](https://github.com/nuxt-community/nuxt-i18n/commit/bea56a90947e1bc767efe036644437f47a9d148f))


### Bug Fixes

* redirect from 404 to defaultLocale if there is matching route ([e99978d](https://github.com/nuxt-community/nuxt-i18n/commit/e99978dcba6ecea19c915e9aa6b5865dab2bc3b8)), closes [#677](https://github.com/nuxt-community/nuxt-i18n/issues/677) [#491](https://github.com/nuxt-community/nuxt-i18n/issues/491)

### [6.10.1](https://github.com/nuxt-community/nuxt-i18n/compare/v6.10.0...v6.10.1) (2020-04-23)


4 changes: 4 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ module.exports = {
}
},
themeConfig: {
algolia: {
apiKey: '3e37c242d902c4d6c469abc8573b7533',
indexName: 'nuxt-i18n'
},
repo: 'nuxt-community/nuxt-i18n',
editLinks: true,
docsDir: 'docs',
6 changes: 4 additions & 2 deletions docs/es/options-reference.md
Original file line number Diff line number Diff line change
@@ -23,8 +23,10 @@ Aquí están todas las opciones disponibles al configurar el módulo y sus valor
// - code of ISO 639-1 and code of ISO 3166-1 alpha-2, with a hyphen (e.g. 'en-US')
locales: [],

// The app's default locale, URLs for this locale won't have a prefix if
// strategy is prefix_except_default
// The app's default locale.
// When using 'prefix_except_default' strategy, URLs for this locale won't have a prefix.
// It's recommended to set this to some locale regardless of chosen strategy, as it will be
// used as a locale fallback to use when navigating to a non-existent route.
defaultLocale: null,

// Separator used to generated routes name for each locale, you shouldn't
10 changes: 7 additions & 3 deletions docs/es/routing.md
Original file line number Diff line number Diff line change
@@ -63,8 +63,8 @@ Con esta estrategia, todas las rutas tendrán un prefijo de configuración local
Esta estrategia combina los comportamientos de ambas estrategias anteriores, lo que significa que obtendrá URL con prefijos para cada idioma, pero las URL para el idioma predeterminado también tendrán una versión sin prefijo.
Para configurar la estrategia, use la opción `strategy`. Asegúrese de tener un `defaultLocale` definido si usa **prefix_except_default**, **prefix_and_default** o la estrategia **no_prefix**.
Para configurar la estrategia, use la opción `strategy`.
Make sure that you have a `defaultLocale` defined, especially if using **prefix_except_default**, **prefix_and_default** or **no_prefix** strategy. For other strategies it's also recommended to set it as it's gonna be used as a fallback when attempting to redirect from 404 page.
```js
// nuxt.config.js
@@ -151,9 +151,10 @@ pages/
├── _nested/
├──── _route/
├────── index.vue
├────── _.vue
```
Así es como configuraría esta página en particular en la configuración:
Así es como configuraría estas páginas en particular en la configuración:
```js
// nuxt.config.js
@@ -163,6 +164,9 @@ Así es como configuraría esta página en particular en la configuración:
pages: {
'_nested/_route/index': {
en: '/mycustompath/:nested/:route?' // Params need to be put back here as you would with vue-router
},
'_nested/_route/_': {
en: '/mycustompath/:nested/*' // * will match the entire route path after /:nested/
}
}
}]
6 changes: 4 additions & 2 deletions docs/options-reference.md
Original file line number Diff line number Diff line change
@@ -36,8 +36,10 @@ Here are all the options available when configuring the module and their default
// - code of ISO 639-1 and code of ISO 3166-1 alpha-2, with a hyphen (e.g. 'en-US')
locales: [],

// The app's default locale, URLs for this locale won't have a prefix if
// strategy is prefix_except_default
// The app's default locale.
// When using 'prefix_except_default' strategy, URLs for this locale won't have a prefix.
// It's recommended to set this to some locale regardless of chosen strategy, as it will be
// used as a locale fallback to use when navigating to a non-existent route.
defaultLocale: null,

// Separator used to generated routes name for each locale, you shouldn't
12 changes: 8 additions & 4 deletions docs/routing.md
Original file line number Diff line number Diff line change
@@ -66,8 +66,8 @@ This strategy combines both previous strategies behaviours, meaning that you wil
### Configuration
To configure the strategy, use the `strategy` option. Make sure that you have a `defaultLocale` defined if using **prefix_except_default**, **prefix_and_default** or **no_prefix** strategy.
To configure the strategy, use the `strategy` option.
Make sure that you have a `defaultLocale` defined, especially if using **prefix_except_default**, **prefix_and_default** or **no_prefix** strategy. For other strategies it's also recommended to set it as it's gonna be used as a fallback when attempting to redirect from 404 page.
```js
// nuxt.config.js
@@ -163,16 +163,17 @@ Localized routes are full URIs, so keep in mind that:
#### Example 1
Say you have some nested page like:
Say you have some nested pages like:
```asciidoc
pages/
├── _nested/
├──── _route/
├────── index.vue
├────── _.vue
```
Here's how you would configure this particular page in the configuration:
Here's how you would configure these particular pages in the configuration:
```js
// nuxt.config.js
@@ -182,6 +183,9 @@ Here's how you would configure this particular page in the configuration:
pages: {
'_nested/_route/index': {
en: '/mycustompath/:nested/:route?' // Params need to be put back here as you would with vue-router
},
'_nested/_route/_': {
en: '/mycustompath/:nested/*' // * will match the entire route path after /:nested/
}
}
}]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-i18n",
"version": "6.10.1",
"version": "6.11.0",
"description": "i18n for Nuxt",
"license": "MIT",
"contributors": [
@@ -23,6 +23,7 @@
},
"scripts": {
"dev:basic": "nuxt -c ./test/fixture/basic/nuxt.config.js",
"dev:basic:generate": "nuxt generate -c ./test/fixture/basic/nuxt.config.js",
"coverage": "codecov",
"lint": "eslint --ext .js,.vue,.ts src test types",
"test": "yarn test:types && yarn test:unit && yarn test:e2e-ssr && yarn test:e2e-browser",
3 changes: 0 additions & 3 deletions src/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -3,9 +3,6 @@ const packageJson = require('../../package.json')
// Internals
exports.MODULE_NAME = packageJson.name
exports.ROOT_DIR = 'nuxt-i18n'
exports.HELPERS_PATH = 'helpers/'
exports.PLUGINS_DIR = 'plugins/'
exports.TEMPLATES_DIR = 'templates/'
exports.LOCALE_CODE_KEY = 'code'
exports.LOCALE_ISO_KEY = 'iso'
exports.LOCALE_DOMAIN_KEY = 'domain'
45 changes: 18 additions & 27 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ const { directive: i18nExtensionsDirective } = require('@intlify/vue-i18n-extens
const {
MODULE_NAME,
ROOT_DIR,
PLUGINS_DIR,
TEMPLATES_DIR,
DEFAULT_OPTIONS,
NESTED_OPTIONS,
LOCALE_CODE_KEY,
@@ -22,9 +20,6 @@ const {
} = require('./helpers/utils')

module.exports = function (userOptions) {
const pluginsPath = join(__dirname, PLUGINS_DIR)
const templatesPath = join(__dirname, TEMPLATES_DIR)
const requiredPlugins = ['main', 'routing']
const options = { ...DEFAULT_OPTIONS, ...userOptions, ...this.options.i18n }
// Options that have nested config options must be merged
// individually with defaults to prevent missing options
@@ -83,31 +78,27 @@ module.exports = function (userOptions) {
console.warn('[' + options.MODULE_NAME + '] The `forwardedHost` option is deprecated. You can safely remove it. See: https://github.com/nuxt-community/nuxt-i18n/pull/630.')
}

// Plugins
for (const file of requiredPlugins) {
this.addPlugin({
src: resolve(pluginsPath, `${file}.js`),
fileName: join(ROOT_DIR, `plugin.${file}.js`),
options: templatesOptions
})
}
const templatesPath = join(__dirname, '/templates')

// Templates
// Templates (including plugins)
for (const file of readdirSync(templatesPath)) {
this.addTemplate({
src: resolve(templatesPath, file),
fileName: join(ROOT_DIR, file),
options: templatesOptions
})
}
if (file.startsWith('plugin.')) {
if (file === 'plugin.seo.js' && !options.seo) {
continue
}

// SEO plugin
if (options.seo) {
this.addPlugin({
src: resolve(pluginsPath, 'seo.js'),
fileName: join(ROOT_DIR, 'plugin.seo.js'),
options: templatesOptions
})
this.addPlugin({
src: resolve(templatesPath, file),
fileName: join(ROOT_DIR, file),
options: templatesOptions
})
} else {
this.addTemplate({
src: resolve(templatesPath, file),
fileName: join(ROOT_DIR, file),
options: templatesOptions
})
}
}

// Add vue-i18n to vendors if using Nuxt 1.x
Loading