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)

Most upvoted comments

If you do not want changeLanguage('en-US') to be called, and therefore want to assert that allLanguages.includes(currentLanguage) when a language change occurs, then you cannot do so while config.load === 'languageOnly'.

If the intended behavior is for someone who prefers 'en-US' to have their language set to 'en', and to not support a whitelist that has regional locales, then you can assert something like allLanguages.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 that allLanguages will always include currentLanguage and that the only languages that we attempt to use are the ones that are on our whitelist.