-
-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsupported language is automatically added to preload option #2178
Comments
Extending the preload option is expecetd... but I agree that only supportedLngs should be handled... |
Wonderful, thank you for such a quick response! I’ll test it out tomorrow 🎉 |
If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project. There are many ways to help this project 🙏 |
I've just pulled this down to test, and I've realized that I made a mistake in my initial report. The This means that if a request comes through for loading FWIW I don't necessarily think this requires another change in i18next, although I agree with the extent of change you've made. This is probably specific to my project, however I'm not too sure how best I should be handling this. I've read through #1687 - it makes sense but doesn't quite address the case I've got. What I've ended up doing is hijacking the |
The main question is: why are you trying to avoid those requests? |
If a users' browser has several regional language preferences, which are seen by the express server after which a matching supported language is chosen, all of the unsupported languages will still remain in i18next and it will continue to try and load them, failing always. This doesn't really have any substantial impact on the application, and it leads to some "known failures" within telemetry, but the residue doesn't seem like a good thing. There are fixed regional languages that we support. There are steps to normalize a user into one of those supported regional languages, and once normalized the user remains normalized, which is why it's a bit of residue to keep attempting to load the known unsupported regional languages. |
if you have a known list of supported (regional) languages, just add them via supportedLngs... |
It doesn't make a difference if I add them via Regardless of Here's a different question for you - is there a more appropriate way for me to normalize from |
You could write your own language detector... |
You could also just use the https://github.com/i18next/i18next-browser-languageDetector convertDetectedLanguage: (lng) => {
if (lng === 'en-NZ') return 'en-US'
return lng
} |
I do want to keep the bells and whistles of the i18next language detector, however |
It seems |
It was not yet implemented.... please try with v3.6.0 |
Tried with 3.6.0 - while that does work to normalize the detected language, the original unsupported regional language ( I may need to create a minimal reproduction to share. I won't be able to do that immediately but will report back here once I get a chance to |
Hi there,
On my express server, I am using the
supportedLngs
andpreload
options, andi18next-http-backend
is configured to reload resources at a specified interval, via thereloadInterval
option.My array of supported languages is
['en-US', 'fr-FR']
, for example.My
preload
array is also['en-US', 'fr-FR']
.I have
fallbackLng
configured such that when loadingen-NZ
, the fallback ofen-US
will be used, becauseen-NZ
is not supported and my backend will return an error.The issue I am facing is with the following line in particular, which extends the
preload
array with any new languages that are encountered, even if they are unsupported.i18next/src/i18next.js
Line 500 in c9e2bf5
Thus, what I observe is that during normal operation where i18n has only seen requests for
en-US
orfr-FR
, those two languages are reloaded periodically.But when a request comes through asking for
en-NZ
translations (perhaps via the Accept-Language header), although i18n will fallback to en-US correctly, the periodic reload continues to includeen-NZ
. Thus I see successful reloads ofen-US
andfr-FR
as expected, but also failures of loading the translations foren-NZ
, which will always fail as it is unsupported.Is this a bug? Should the extension of the preload array be opt-in, or conditional on it being a part of supported languages? I'm not quite sure what the process should be here, but extending the user-configured preload array without any check feels a bit fishy. What would you suggest?
I can share a minimal reproduction if that will help. Thank you in advance!
The text was updated successfully, but these errors were encountered: