This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Changing locale and then going back negates locale change nextjs 14 #700
Labels
You can continue the conversation there. Go to discussion →
Description
When I change locale via the LocaleSwitcher from the example I see the page in German.
However when I click back in the browser I see the page in English again.
My use case is a nextjs app which is embedded in a react-native-web-view and has a dedicated page for changing the language. When the user changes the language there is a back button to navigate away which uses the normal
router.back
command. Due to the described behaviour when the user navigates back the locale change is overridden.As a workaround for now I will have a local copy of the history so that I am able to go back by pushing a new url and not via the
router.back
.PS: I was not able to fork the bug template in CodeSandbox. Please check permissions or something.
Mandatory reproduction URL (CodeSandbox or GitHub repository)
https://codesandbox.io/p/sandbox/next-intl-bug-template-app-forked-zcymvq
Reproduction description
Steps to reproduce:
Result: Content is in English
Expected Result: Content is in German
Expected behaviour
I would expect that when I change the language and go back it will keep the new language. I understand that the URL has precedence over the next-intl cookie however I don't think this is the correct behaviour. If I have already selected my language for the site (and thus have my next-intl cookie set) I should be able to open any link (regardless of the locale) and automatically see the site in my selected locale. Therefore the precedence should be the cookie. When the URL changes the library should monitor the locale parameters and sync it with the cookie via router.replace to ensure consistency with the desired locale and back - forward movement works.
The text was updated successfully, but these errors were encountered: