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.

Default locale & browser language detection confusion

See original GitHub issue

Version

v5.0.3

Reproduction link

https://github.com/nuxt-community/nuxt-i18n

Steps to reproduce

Quoting @mapeal2 https://cmty.app/nuxt/nuxt-i18n/issues/c96

Given 2 locales ('en', 'fr'), default locale is 'en' and the preferred browser language is 'fr', with the 'prefixexceptdefault' option, the steps to reproduce it would be:
Visit home page '/' --> browser language is detected and redirected to '/fr', which is correct.
Close the browser.
Open a new browser and enter the home page ('/') again 

What is expected ?

I would expect that, when opening the home page again, the application would be redirected to '/fr' instead of staying in '/'.

What is actually happening?

 'en' locale is chosen, ignoring cookie.
<div align="right">This bug report is available on Nuxt community (#c116)</div>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
rchlcommented, May 9, 2019

Fix is integrated. This can be resolved.

1reaction
Aperrixcommented, Nov 11, 2018

Same bug with v5.4.4 of nuxt-i18n (inspired by nuxt-i18n example of @paulgv )

modules: ['nuxt-i18n' {
  locales: [
    { code: 'fr', iso: 'fr-FR', name: 'Français' },
    { code: 'en', iso: 'en-GB', name: 'English' },
    { code: 'de', iso: 'de-DE', name: 'Deutsch' },
    { code: 'es', iso: 'es-ES', name: 'Español' },
    { code: 'it', iso: 'it-IT', name: 'Italiano' },
    { code: 'pt', iso: 'pt-PT', name: 'Português' }
  ],
  defaultLocale: 'en',
  detectBrowserLanguage: {
    useCookie: true,
    alwaysRedirect: true
  },
  vueI18n: {
    messages: { fr, en, de, es, it, pt }
  }
}],

(alwaysRedirect variable found here : https://github.com/nuxt-community/nuxt-i18n/pull/148/commits/38b0cbbf9033e5ffe128aa776e0f6f4ee03076af) image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default locale & browser language detection confusion · Issue ...
Given 2 locales ('en', 'fr'), default locale is 'en' and the preferred browser language is 'fr', with the 'prefixexceptdefault' option, ...
Read more >
Solved: How to Detect a User's Locale in a Web App | Phrase
In this article, we'll go through three different ways of detecting a user's locale: through the browser's navigator. language s (on the client ......
Read more >
Browser language detection and redirect vs Google Robots
I try to automatically detect browser language and redirect user to proper page according to his language. Site is bilingual, default ...
Read more >
Identifying Language and Locale with DeviceAtlas
For a default browser, this data is highly indicative of the language of the user of the device as well as the local...
Read more >
Language and locale resolution overview - Android Developers
Your app's default language is en_US (US English), and it also has Spanish strings localized in es_ES resource files.
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