Default language not working as expected
See original GitHub issueSummary 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:
- English (en)
- French (fr)
- Spanish (es)
Version used:
"gatsby": "^3.10.1"
"i18next": "^20.4.0"
"react-i18next": "^11.11.4"
"gatsby-plugin-react-i18next": "^1.1.1"
Gatsby configuration:
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/locales`,
name: `locale`,
},
},
{
resolve: `gatsby-plugin-react-i18next`,
options: {
localeJsonSourceName: `locale`,
defaultLanguage: "es",
languages: ["es", "fr", "en"],
siteUrl: `http://mysite.com/`,
i18nextOptions: {
interpolation: {
escapeValue: false,
},
keySeparator: false,
nsSeparator: false,
},
},
},
...
...
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:13 (2 by maintainers)
Top Results From Across the Web
java - Change language not working when device default ...
I have problem to change language when my device language not be English (For example Portuguese). This is my code:
Read more >Default language not working properly - Drupal Answers
Everything works as expected but there is one problem: when the site is loaded it takes the English as default language. Then if...
Read more >Survey123 Default Language Not Working - Esri Community
I'm creating a Survey123 form that is intended to default to French, which needs to include all the buttons and "Page 1 of...
Read more >Tips for Troubleshooting the Default Language of a Job ...
First, check the Job Requisition XML defaultlocale definition. If the expected default locale does not appear, then check the default language in Admin ......
Read more >Default language not working - Google Groups
Since Enketo introduced a feature to sync UI and form language, the default form language defined in the form may not do what...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @AnderUstarroz , I have added
generateDefaultLanguagePage: true
andredirect: false
to options and it work for meGuys, sorry to say, but read the docs…
Setting a
defaultLanguage
means that you will render this language, when the user navigates to root/
. Instead of navigating him/her to/${defaultLanguage}
it will show the index page with your choice.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
gatsby-node.js
file or add a router into yourpages/index.js
for instance. If you want to know more, I am available for help.