nuxt-i18n
Advanced tools
Comparing version 6.12.0 to 6.12.1-beta.0
@@ -0,1 +1,10 @@ | ||
### [6.12.1-beta.0](https://github.com/nuxt-community/nuxt-i18n/compare/v6.12.0...v6.12.1-beta.0) (2020-05-26) | ||
### Bug Fixes | ||
* don't add trailing slashes to generated routes ([4825d61](https://github.com/nuxt-community/nuxt-i18n/commit/4825d6106bde71baa245875a97dfa0d88834b190)), closes [#717](https://github.com/nuxt-community/nuxt-i18n/issues/717) | ||
* favor non-prefixed route with prefix_and_default strategy ([#732](https://github.com/nuxt-community/nuxt-i18n/issues/732)) ([09d2c0f](https://github.com/nuxt-community/nuxt-i18n/commit/09d2c0ff39089802db67b2db9c67e46d93fda64d)), closes [#721](https://github.com/nuxt-community/nuxt-i18n/issues/721) | ||
* remove "encodePaths" option and don't encode paths by default ([#731](https://github.com/nuxt-community/nuxt-i18n/issues/731)) ([aba92b3](https://github.com/nuxt-community/nuxt-i18n/commit/aba92b318559521c268d2d3bbe427653bb4c14d6)), closes [#712](https://github.com/nuxt-community/nuxt-i18n/issues/712) | ||
## [6.12.0](https://github.com/nuxt-community/nuxt-i18n/compare/v6.11.1...v6.12.0) (2020-05-25) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "nuxt-i18n", | ||
"version": "6.12.0", | ||
"version": "6.12.1-beta.0", | ||
"description": "i18n for Nuxt", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -51,3 +51,2 @@ const packageJson = require('../../package.json') | ||
pages: {}, | ||
encodePaths: true, | ||
beforeLanguageSwitch: () => null, | ||
@@ -54,0 +53,0 @@ onLanguageSwitched: () => null |
@@ -6,13 +6,13 @@ const { STRATEGIES } = require('./constants') | ||
exports.makeRoutes = (baseRoutes, { | ||
locales, | ||
defaultLocale, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix, | ||
differentDomains, | ||
isNuxtGenerate, | ||
strategy, | ||
parsePages, | ||
locales, | ||
pages, | ||
encodePaths, | ||
pagesDir, | ||
differentDomains | ||
parsePages, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash | ||
}) => { | ||
@@ -80,9 +80,11 @@ locales = getLocaleCodes(locales) | ||
if (componentOptions.paths && componentOptions.paths[locale]) { | ||
path = encodePaths ? encodeURI(componentOptions.paths[locale]) : componentOptions.paths[locale] | ||
path = componentOptions.paths[locale] | ||
} | ||
const isDefaultLocale = locale === defaultLocale | ||
// For PREFIX_AND_DEFAULT strategy and default locale: | ||
// - if it's a parent route, add it with default locale suffix added (no suffix if route has children) | ||
// - if it's a child route of that extra parent route, append default suffix to it | ||
if (locale === defaultLocale && strategy === STRATEGIES.PREFIX_AND_DEFAULT) { | ||
if (isDefaultLocale && strategy === STRATEGIES.PREFIX_AND_DEFAULT) { | ||
if (!isChild) { | ||
@@ -119,3 +121,3 @@ const defaultRoute = { ...localizedRoute, path } | ||
// Skip default locale if strategy is PREFIX_EXCEPT_DEFAULT | ||
!(locale === defaultLocale && strategy === STRATEGIES.PREFIX_EXCEPT_DEFAULT) | ||
!(isDefaultLocale && strategy === STRATEGIES.PREFIX_EXCEPT_DEFAULT) | ||
) | ||
@@ -125,11 +127,18 @@ | ||
path = `/${locale}${path}` | ||
} | ||
if (locale === defaultLocale && strategy === STRATEGIES.PREFIX && isNuxtGenerate) { | ||
routes.push({ | ||
path: route.path, | ||
redirect: path | ||
}) | ||
} | ||
// - Follow Nuxt and add or remove trailing slashes depending on "router.trailingSlash` | ||
// - If "router.trailingSlash" is not specified then default to no trailing slash (like Nuxt) | ||
// - Children with relative paths must not start with slash so don't append if path is empty. | ||
if (path.length) { // Don't replace empty (child) path with a slash! | ||
path = path.replace(/\/+$/, '') + (trailingSlash ? '/' : '') || (isChildWithRelativePath ? '' : '/') | ||
} | ||
if (shouldAddPrefix && isDefaultLocale && strategy === STRATEGIES.PREFIX && isNuxtGenerate) { | ||
routes.push({ | ||
path: route.path, | ||
redirect: path | ||
}) | ||
} | ||
localizedRoute.path = path | ||
@@ -136,0 +145,0 @@ |
@@ -58,2 +58,3 @@ const { resolve, join } = require('path') | ||
if (localeCodes.length) { | ||
const { trailingSlash } = this.options.router | ||
let isNuxtGenerate = false | ||
@@ -69,3 +70,4 @@ const extendRoutes = routes => { | ||
pagesDir, | ||
isNuxtGenerate | ||
isNuxtGenerate, | ||
trailingSlash | ||
}) | ||
@@ -72,0 +74,0 @@ routes.splice(0, routes.length) |
@@ -58,6 +58,7 @@ import './middleware' | ||
if (route.path && !route.name) { | ||
const isDefaultLocale = locale === defaultLocale | ||
// if route has a path defined but no name, resolve full route using the path | ||
const isPrefixed = ( | ||
// don't prefix default locale | ||
!(locale === defaultLocale && strategy === STRATEGIES.PREFIX_EXCEPT_DEFAULT) && | ||
const isPrefixed = | ||
// don't prefix default locale | ||
!(isDefaultLocale && [STRATEGIES.PREFIX_EXCEPT_DEFAULT, STRATEGIES.PREFIX_AND_DEFAULT].includes(strategy)) && | ||
// no prefix for any language | ||
@@ -67,3 +68,2 @@ !(strategy === STRATEGIES.NO_PREFIX) && | ||
!i18n.differentDomains | ||
) | ||
@@ -70,0 +70,0 @@ const path = (isPrefixed ? `/${locale}${route.path}` : route.path) |
@@ -69,7 +69,7 @@ import VueMeta from 'vue-meta' | ||
for (const [iso, locale] of localeMap.entries()) { | ||
for (const [iso, mapLocale] of localeMap.entries()) { | ||
link.push({ | ||
hid: `alternate-hreflang-${iso}`, | ||
rel: 'alternate', | ||
href: baseUrl + this.switchLocalePath(locale.code), | ||
href: baseUrl + this.switchLocalePath(mapLocale.code), | ||
hreflang: iso | ||
@@ -76,0 +76,0 @@ }) |
@@ -63,3 +63,2 @@ import VueI18n from 'vue-i18n' | ||
detectBrowserLanguage?: DetectBrowserLanguageInterface | ||
encodePaths?: boolean | ||
langDir?: string | null | ||
@@ -66,0 +65,0 @@ lazy?: boolean |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98706
1388
2