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

Automatic locale detection only working on index page #20657

Closed
Luisdv93 opened this issue Jan 1, 2021 · 2 comments
Closed

Automatic locale detection only working on index page #20657

Luisdv93 opened this issue Jan 1, 2021 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@Luisdv93
Copy link

Luisdv93 commented Jan 1, 2021

Bug report

Describe the bug

To reproduce the behaviour I cloned the i18n-routing example. The gist is that the automatic locale detection only seems to be working if I visit the index page on the first load. The Next.js docs says this:

When a user visits the application root (generally /), Next.js will try to automatically detect which locale the user prefers based on the Accept-Language header and the current domain.

Shouldn't this be the behaviour for other pages as well? Is there any way to configure this right now?

To Reproduce

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

Here's a repo where it can be tested. The only change I made to the original repo was adding "es" and "en" as locales and setting "es" as default.

Repo

  1. Set your browser locale to english
  2. Open a new tab and go directly (not the index) to any of the defined routes like /gsp/first or /gssp
  3. Navigate to other routes with the links provided
  4. See the path not updating to /en

Expected behavior

If you visit the / page on first load you see that next updates the url to display the /en and showing the current locale as "en." I was hoping for this to be the behaviour for all routes.

My use case is a fairly simple one where I'm sending a route to my app on an email and I want to be able to display the app in the selected locale without having to send it directly in the email.

Screenshots

Index on first load
image

Any other route on first load
image

System information

  • OS: Windows 10
  • Browser: Chome v87
  • Version of Next.js: latest
  • Version of Node.js: 14.15.1

Additional context

@Luisdv93 Luisdv93 added the bug Issue was opened via the bug report template. label Jan 1, 2021
@ijjk
Copy link
Member

ijjk commented Jan 1, 2021

Hi, this is the expected behavior currently per the documentation here https://nextjs.org/docs/advanced-features/i18n-routing#automatic-locale-detection As mentioned in the RFC here #17078 we do plan to investigate locale detection on non-index paths as well in the future!

I'm going to close this since this isn't a bug and is currently expected and is documented.

@ijjk ijjk closed this as completed Jan 1, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants