i18n
i18n copied to clipboard
It seems only the named router will work when using custom paths
Version
@nuxtjs/i18n: "7.0.1" nuxt: ^2.15.0
@nuxtjs/i18n configuration
modules: [
[
"@nuxtjs/i18n",
{
locales: [
{
code: "en",
iso: "en-GB",
file: "en-GB.js",
name: "ENG"
},
{
code: "nl",
iso: "nl-NL",
file: "nl-NL.js",
name: "NL"
}
],
lazy: true,
langDir: "lang/",
detectBrowserLanguage: false,
defaultLocale: "nl",
vueI18n: {
fallbackLocale: "nl"
},
parsePages: false,
pages: {
"product/_id": {
nl: "/producten/:id?",
en: "/product/:id?"
},
"user/profile/index": {
nl: "/gebruiker/profiel",
en: "/user/profile"
}
}
}
]
]
What is Expected?
localePath('/product/123')"
work when using custom paths
What is actually happening?
localePath('/product/123')"
path route : failed,
but localePath({ name: 'product-id', params: { id: '123' } })
named route : work.
reproducible repo
https://codesandbox.io/s/test-nuxt-i18n-6n9se
There was a similar bug that was fixed before (https://github.com/nuxt-community/i18n-module/issues/641) but I guess it only covered the case of non-dynamic routes. For dynamic routes the https://github.com/nuxt-community/i18n-module/issues/984 might be actually required.
There was a similar bug that was fixed before (#641) but I guess it only covered the case of non-dynamic routes. For dynamic routes the #984 might be actually required.
Thanks @rchl , Could you have a check at my reproducible repo (https://codesandbox.io/s/test-nuxt-i18n-6n9se), it seems not working for neither non-dynamic routes nor dynamic routes.
It appears that the logic introduced in the #641 fix only works if passing the path of the default locale. In your case it's nl
so it doesn't match when you use /user/profile
.
To really fix it we would need to aforementioned feature implemented.
BTW. Your custom paths for the product/_id
route should be:
"product/_id": {
nl: "/producten/:id?",
en: "/product/:id?"
},
hi @rchl , thanks. yeah, it works well with the default locale. And thank you for pointing out my mistake.