-
Notifications
You must be signed in to change notification settings - Fork 72
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
Default language not working as expected #89
Comments
I am having the same issue, is the latest version of the plugin broken? |
same issue here, and very confusing about that |
In my case, I tested this scenario
|
@peterschwarzdev @AnderUstarroz I think I found the root cause, the plugin will store the language setting in the localstorage and then try to re-use it in the future, so if you test the page in one language, then even you change language of your browser, it will remain the old one. You can see the code here
I understood why use localstorage, but I think sessionstorage will be a better choice here. As a workaround, On the top of the page, you can add this code to remove the localstorage first. if (typeof window !== "undefined") { |
I've created a pull request here #91 |
Hey @chenxizhang thanks for debugging, but I am not sure that is the root question of the issue, because I was continuously deleting LocalStorage but still when I was calling http://mysite.com/ (with empty LocalStorage) I was being redirected to http://mysite.com/en/ so it seems that when you set some default language instead of English (but having English as an available language) somehow defaults to English. 🤷♂️ Nonetheless If I remove
|
You can try to add |
I have the same issue! @chenxizhang I've tried your solutions but they didn't work for me :( I know it's ridiculous, but I think the plugin choose the first language in |
How did it go? |
Guys, sorry to say, but read the docs... Setting a It is super tricky to be honest. I am also struggling with many side effects, but the developers have done stuff intentionally. And pushing such PR like @chenxizhang did is a huge provocation. At least you could have stuck to the code style convention. Instead of reading the documentation you're pushing such heavily unreflected changes to all of us? C'mon, you can do a better job! If you want to gain full control of your client routes, you will probably need to implement a |
I still think that is quite reasonable expecting that defining |
Hi @AnderUstarroz , I have added |
This is due to the downstream of Additionally i've raised an issue here to try and move away from |
Summary of the issue
Default language not working as expected. Default language is set to Spanish (es), but the root page gets redirected to English (en)
Expected behavior
✅ When visiting the index page http://mysite.com/ it should load the page normally using the default language Spanish (es)
Current behavior
❗ When visiting the index page http://mysite.com/ it gets automatically redirected to http://mysite.com/en/
Setup details
The allowed languages for the site are:
Version used:
Gatsby configuration:
The text was updated successfully, but these errors were encountered: