Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detectBrowserLanguage does not work in production #2984

Closed
J43fura opened this issue Jun 20, 2024 · 6 comments
Closed

detectBrowserLanguage does not work in production #2984

J43fura opened this issue Jun 20, 2024 · 6 comments

Comments

@J43fura
Copy link

J43fura commented Jun 20, 2024

Environment


  • Operating System: Linux
  • Node Version: v20.11.0
  • Nuxt Version: 3.11.1
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.4
  • Package Manager: npm@10.5.2
  • Builder: -
  • User Config: srcDir, imports, $development, app, runtimeConfig, modules, primevue, i18n, postcss, css, supabase
  • Runtime Modules: @nuxt/test-utils/module@3.12.0, @nuxtjs/supabase@1.1.7, @nuxtjs/tailwindcss@6.11.4, @pinia/nuxt@0.5.1, nuxt-primevue@0.3.1, @nuxtjs/i18n@8.3.1
  • Build Modules: -

Reproduction

  • The configuration:
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    strategy: 'no_prefix',
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected',
      redirectOn: 'root', // recommended
    },
  },
  • Run npm run generate

Describe the bug

  • Locally in development mode (npm run dev): The cookie is set correctly with the browser locale being its value, works as expected ✔️
  • Production (npm run generate): The cookie's value is set to the defaultLocale instead ❌

Additional context

No response

Logs

No response

Copy link

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 Reproduction starter (v8 and higher)
👉 Reproduction starter (edge)

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@kazupon kazupon added the v8 label Jun 24, 2024
@J43fura
Copy link
Author

J43fura commented Jun 24, 2024

@J43fura
Copy link
Author

J43fura commented Jun 26, 2024

@kazupon here is the reproduction: https://stackblitz.com/edit/github-oyrjnm?file=app.vue

@codeofsumit
Copy link

I have the same problem - came here trying to debug this and find a solution. With nuxt generate, cookies and browser language are ignored - it's always the default language (and the cookie value is overwritten to the default language on load)

@BobbieGoede
Copy link
Collaborator

This should be resolved by #3087 which is included in the latest patch release so I'll close this, let me know if you have any questions!

@codeofsumit
Copy link

I can confirm it works again - thank you for the fix! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants