Next.js: Automatic locale detection changes default locale

Created on 3 Nov 2020  路  3Comments  路  Source: vercel/next.js

Bug report

Describe the bug

Let's say I have this in my next.config.js:

module.exports = {
  i18n: {
    locales: ['en', 'fr', 'nl', 'sv'], // 'sv' is my browser language
    defaultLocale: 'en',
  },
}

If I browse to /en/gsp/random-slug i get redirected to /gsp/random-slug. The current locale and defaultLocale is set to en. All fine! But if I refresh the page the url stays the same but locale and defaultLocale is set to sv.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Clone https://github.com/vercel/next.js/tree/canary/examples/i18n-routing
  2. Add your browser language to next.config.js (if 'en', set another one as default)
  3. Go to http://localhost:3000/en/gsp/random-slug
  4. When redirected to http://localhost:3000/gsp/random-slug, refresh the page

Expected behavior

To keep both the locale and defaultLocale as 'en' after refresh.

System information

  • OS: macOS
  • Browser: chrome
  • Version of Next.js: 10.0.0
  • Version of Node.js: 14.15.0
bug

Most helpful comment

Oh. Yes, it was already fixed! Sorry for that. Will check canary next time.

All 3 comments

Can you check next@canary, this is potentially already fixed

Oh. Yes, it was already fixed! Sorry for that. Will check canary next time.

No worries at all!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knipferrc picture knipferrc  路  3Comments

flybayer picture flybayer  路  3Comments

timneutkens picture timneutkens  路  3Comments

rauchg picture rauchg  路  3Comments

renatorib picture renatorib  路  3Comments