question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change browser language detection to only redirect from default locale route

See original GitHub issue

What problem does this feature solve?

When using strategies with prefixes, and detectBrowserLanguage enabled, when user goes directly to a route with non-default locale, it would be better if we didn’t redirect to browser’s locale. The user’s intention, in theory, was to visit the site in that specific locale

Some more context in #451

What does the proposed changes look like?

Only redirect and change locale if first navigation is to route that matches defaultLocale.

That would be a breaking change and would require major version.

<div align="right">This feature request is available on Nuxt community (#c301)</div>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:9

github_iconTop GitHub Comments

5reactions
konr4dcommented, Nov 19, 2019

@laurentdebricon A quick workaround https://github.com/konr4d/nuxt-i18n/commit/37f394dba13c055faae1890d7d2d6997a25904e5

Edit: I was able to make nuxt-i18n redirect from root path only and respect the saved cookie. E.g., a new user from France is initially redirected to /fr per hers/his Accept-Language. Then, every / entry results in a redirect to a locale path based on the value in that cookie. I wish I had time to write a proper non-kludge code and form it into a PR. Alas, for now it lives but here: https://github.com/konr4d/nuxt-i18n/tree/only-root-redirect

3reactions
rchlcommented, Sep 10, 2020

Fix released in v6.15.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change browser language detection to only redirect from ...
Only redirect and change locale if first navigation is to route that matches defaultLocale . That would be a breaking change and would...
Read more >
Advanced Features: Internationalized Routing - Next.js
When localeDetection is set to false Next.js will no longer automatically redirect based on the user's preferred locale and will only provide locale...
Read more >
Redirection to english version if browser language is not russian
1 Answer 1 ; language || navigator.userLanguage ; if (navLang != 'ru-RU'){ ; var path = window ; pathname; // Redirect to an...
Read more >
Browser language detection and redirect - Performance
I want the Cloudflare to detect the preferred browser language and redirect the user to the appropriate language.
Read more >
Browser language detection - i18n-module
Browser language is detected either from navigator when running on client-side, or from the accept-language HTTP header. Configured locales (or locales iso and/ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found