Home > Software engineering >  i18next not detecting language variation, eg: en-us
i18next not detecting language variation, eg: en-us

Time:03-30

When I set in my browser a language variation, for example: English (United States) / en-us. The i18next library doesn't detect that variation and just loads the next language in the list, for example: Spanish or plain English.

enter image description here

CodePudding user response:

In order to make i18Next detect language variations, you have to add: nonExplicitSupportedLngs: true, in the i18next config file, for example:

i18next
    ...
    .use(LanguageDetector)
    .init({
        supportedLngs: ['en', 'es'],
        nonExplicitSupportedLngs: true, //support language variation
        ...
    });

Reference: https://www.i18next.com/overview/configuration-options > nonExplicitSupportedLngs

CodePudding user response:

Either remove the supportedLngs option or add nonExplicitSupportedLngs: true.

  • Related