i18next / react-i18next

Internationalization for react done right. Using the i18next i18n ecosystem.
https://react.i18next.com
MIT License
9.23k stars 1.02k forks source link

react-i18next:: i18n.languages were undefined or empty #1803

Open AlemTuzlak opened 1 week ago

AlemTuzlak commented 1 week ago

🐛 Bug Report

I was implementing react-i18next in Remix and I got the error from the title. I guess this isn't technically a bug but I wanted to check with you guys if it made sense to change the behavior a bit or warn the user of the error. What happened is that I had setup everything properly and I by accident set the fallbackLng to be something other than the supportedLngs. Namely, I set the fallbackLng to be en_GB instead of en-GB which silently failed and resulted in the error above in the browser and the server. I switched it to the correct locale and it worked.

I would like to check if you would be open to just adding something like a log message saying "The fallback language you provided does not exist in your supported languages" just to maybe help people in the future who face the same issue

To Reproduce

detection: {
  supportedLanguages: ["en", "de"],
  fallbackLanguage: "random",
},

Expected behavior

Get at least a console log that it doesn't exist in the supportedLanguages

Your Environment

adrai commented 1 week ago

Yes, we're open for such a warning message... something like: https://github.com/i18next/i18next/blob/master/src/i18next.js#L163 feel free to provide a PR in the i18next repository...