Page is not redirect if the browser default lang and cookie i18n_redirected lang are different languages

gokhancetiner
0
gokhancetiner
commented 2 months ago

Hello,

When you first enter the URL localhost:3000 page is redirect to default browser language localhost:3000/tr and cookie i18nredirected is set to 'tr' as well. After you change the language in the application with this.$i18n.setLocale('en') function URL is changed to localhost:3000/en and cookie i18nredirected is set to 'en'
The problem starts at that point open new tab and enters localhost:3000 and page is not redirect to either browserLang nor to cookie i18nredirected lang and get 404. If I set i18nredirected value manually default browser lang that is 'tr' page is redirected correctly to localhost:3000/tr.

As summarized the problem if browserDefaultLang and cookie lang doesn't match redirect doesn't work.

Do you have any idea about that problem?

Configuration in nuxt.config.js

"nuxt-i18n",
{
// Options
strategy: "prefix",
detectBrowserLanguage: {
useCookie: true,
cookieKey: "redirected",
alwaysRedirect: true,
fallbackLocale: 'en'
},
locales: [{
code: "en",
iso: "en-US",
file: "en-US.js"
},
{
code: "fr",
iso: "fr-FR",
file: "fr-FR.js"
},
{
code: "tr",
iso: "tr-TR",
file: "tr-TR.js"
}
],
lazy: true,
langDir: "lang/",
defaultLocale: "en",
parsePages: false,
encodePaths: true,
seo: false
}

0
Informations
Question โ€ข Unresolved
#c398 - Created 2 months ago