https://github.com/nuxt-community/nuxt-i18n
Using Nuxt 1.4.0 and Nuxt i18n 2.6.1, add the following config for the module:
locales: [
{
code: 'de',
iso: 'de-DE',
name: 'German'
},
{
code: 'en',
iso: 'en-US',
name: 'English'
}
],
defaultLocale: 'de',
detectBrowserLanguage: true,
useRedirectCookie: false,
vueI18n: {
fallbackLocale: 'de',
messages: {
'de': require('./locales/de.json'),
'en': require('./locales/en.json')
}
}
If I change the language on my application from english to german the language has to be the same (the last selected) even if I refresh the page.
If I change the language on my application from english to german and then I refresh the page the language should be german.
If I change the language on my application from english to german and then I refresh the page, the module redirects me to the english version automatically instead of keeping the german version.
I think the reason is because this line of code is true practically every time:
If I change that line to this it works well:
if (typeof req.headers['accept-language'] !== 'undefined' && useRedirectCookie) {
Any thoughts?
Thanks in advance! 馃憡馃徏
Hi @eddiesigner
The useRedirectCookie option is actually meant to prevent those excessive redirections, is there any reason your disabled it? I'd recommend you set it to true :)
Oh, I forgot to say, I had that value before but it was the same 馃槥 for that reason I think that line is true every time, it doesn't matter if you put false or true on the useRedirectCookie option.
At least in my application the line numer 40 is always reached :/
Hey @eddiesigner
Sorry for the delay. I looked into the issue and it does look like there were some pretty inconvenient bugs in the middleware 馃槗
I pushed a fix in v2.9.4 which should solve your issue, I hope you can give it a try and give me some updates :)
Awesome! Thank you so much @paulgv! 馃槃
I've already tested it and is working as expected 馃憤
Most helpful comment
Awesome! Thank you so much @paulgv! 馃槃
I've already tested it and is working as expected 馃憤