i18next / i18next-browser-languageDetector

language detector used in browser environment for i18next
MIT License
874 stars 90 forks source link

Pick the first entry from supportedLngs if the browser does not detect any language from supportedLngs array. #292

Closed jordan-rigo closed 3 months ago

jordan-rigo commented 3 months ago

I got the following init configuration:

  i18n.use(LanguageDetector)
  .use(initReactI18next)
  .use(txBackend)
  .init({
    returnNull: false,
    fallbackLng: "en",
    supportedLngs: ["sk", "uk"],
    defaultNS: "common",
    interpolation: {
      escapeValue: false,
    },
    react: {
      transSupportBasicHtmlNodes: true,
    },
  });

I have suppotedLngs sk and uk, but i18next-browser-languageDetector does not even detects those langages from my browser, which is completly reasonable and my translation break.

Should the plugin not pick some language from the supportedLngs? If no match detected just pick the first one from supported array.

adrai commented 3 months ago

Sorry, but I don't understand your issue. Can you please provide a minimal reproducible example repository that shows your issue and explain with more details what you mean? btw: you've set fallbackLng to "en" but "en" is not included in the supportedLngs array

jordan-rigo commented 3 months ago

I was too quick with opening this issue, but this might help someone else.

Pay attention to set the fallbackLng to a language supported in the supportedLngs array

Thank you for your answer!