next-i18next: Get 'language is not included' error on first time page request
When I request page at first time. I get Invalid configuration: Current language is not included in all languages array in the browser console.
Also, If I remove i18next cookie and then refresh the page. The error message is occurred too.
This error message is only occurred when I enable localeSubpaths.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 38 (35 by maintainers)
If you do not want
changeLanguage('en-US')to be called, and therefore want to assert thatallLanguages.includes(currentLanguage)when a language change occurs, then you cannot do so whileconfig.load === 'languageOnly'.If the intended behavior is for someone who prefers
'en-US'to have their language set to'en', and to not support awhitelistthat has regional locales, then you can assert something likeallLanguages.includes(currentLanguage.slice(0, 2)). However, in practice, users’ accept-language headers that contain'en-US'will most likely also include'en'somewhere in it, as well.Setting
config.load = 'currentOnly'ensures thatallLanguageswill always includecurrentLanguageand that the only languages that we attempt to use are the ones that are on ourwhitelist.