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

alwaysRedirect freezing behavior #2262

Closed
pmnzt opened this issue Jul 25, 2023 · 3 comments · Fixed by #2276
Closed

alwaysRedirect freezing behavior #2262

pmnzt opened this issue Jul 25, 2023 · 3 comments · Fixed by #2276

Comments

@pmnzt
Copy link

pmnzt commented Jul 25, 2023

Environment

nuxt 3.6.5
i18n v8-beta.13

Reproduction

https://github.com/pmnzt/nuxt-i18n-repo/tree/issue2

Describe the bug

Relating to #2255 , i tried to set alwaysRedirect to true, it seemed to fix that issue of redirecting to the browser's default locale but now i see another issue, no matter what i change 1 - removing cookies 2 - changing the browser's preferred locale, it still redirects me back to the previous browser's locale (the first time i opened the site) after that the locale would not want to be switched.

1- no matter how many times i change the preferred browser locale and removes cookies.
2 - if a cookie was saved on 'fr' for example Now switching to 'en' which is the defaultLocale in the config, using switchLocalePath(locale.code), does not work in this case.

3 - if the strategy is set to 'prefix' not 'prefix_except_default' , then switching to 'fr' via switchLocalePath, and switching back to 'en' does write the cookie and switch the language all times, however it still redirects to 'fr' not 'en' after reloading on site's root path, even though the cookie was been set to 'en' not 'fr' the last time.

Additional context

No response

Logs

No response

Copy link
Collaborator

kazupon commented Jul 26, 2023

Thank you for your reporting!

I've fixed #2255
I think this issue might be caused by #2255, so Please try to use with edge channel version.

And, Your reproduction is almost unchanged from #2255.
Please give us a reproduction that can be reliably reproduced 🙏

@pmnzt
Copy link
Author

pmnzt commented Jul 26, 2023

@kazupon

I've fixed #2255 I think this issue might be caused by #2255, so Please try to use with edge channel version.

Thanks, But using the edge channel did not fix #2255 for me, using the same reproduction repo.

And, Your reproduction is almost unchanged from #2255. Please give us a reproduction that can be reliably reproduced 🙏

yes it is the same repo, but i added the branch named issue2 for this one, that has the necessary changes to reproduce this issue https://github.com/pmnzt/nuxt-i18n-repo/tree/issue2 .

Copy link
Collaborator

kazupon commented Jul 27, 2023

Thank you for your reproduction updating.

I've understood that detectBrowserLanguage option still has bugs.

detectBrowserLanguage is deeply dependent on the routing strategy, so it might take some time to stabilize.

If you want to use cookies and browser navigator language to control routing, the nuxt i18n module give some API and Nuxt API (navigateTo), so you can custom with using them for your use case.

kazupon added a commit that referenced this issue Jul 30, 2023
kazupon added a commit that referenced this issue Jul 30, 2023
BobbieGoede added a commit to BobbieGoede/i18n that referenced this issue Mar 27, 2024
BobbieGoede added a commit to BobbieGoede/i18n that referenced this issue Mar 27, 2024
DarthGigi pushed a commit to DarthGigi/i18n that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants