nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

detectBrowserLanguage doesn't work #2829

Closed jmuidesign closed 6 months ago

jmuidesign commented 6 months ago

Environment

Reproduction

https://stackblitz.com/edit/nuxt-starter-xkxgkk?file=nuxt.config.ts,pages%2Findex.vue

Describe the bug

The cookie is never set when hit root, whether it's default i18n_redirected or custom test_cookie in my example

Additional context

No response

Logs

No response

BobbieGoede commented 6 months ago

Somehow I remember this working before, but this seems to have been broken when reverting to earlier versions too.. From what I can tell it looks like the tests have never properly tested the cookie being set on page load, only after locale switching 🤔 so this may have never worked as expected (in v8).

Current test https://github.com/nuxt-modules/i18n/blob/eafe06bb561154b67ebbdb75acf8bcb00c8b1df2/specs/browser_language_detection/no_prefix.spec.ts#L39-L45

First version of test https://github.com/nuxt-modules/i18n/blob/b660dc22daf740bee093527f7b49585c4011988d/specs/browser_language_detection/cookie.spec.ts#L25-L34)

Thanks for reporting, I'll work on a fix soon!

jmuidesign commented 6 months ago

Thank you @BobbieGoede 💪