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
GetLanguageFromRequestAsync and Accept-Language header mismatch #7127
Comments
Examples of Accept-Language Header Values
I haven't found any real evidence on how the browser specifies when to use
But my findings seems to suggest when the browser provides a Specific culture, it also provides the neutral as a fallback. |
In the admin area when you edit a Language, inside the view NopCommerce have this piece of code maybe it should be
i have never encountered the need to have two languages for example English (en-GB) and English (en-US). |
Today, I discovered a somewhat odd and peculiar problem with AutomaticallyDetectLanguage and GetLanguageFromRequestAsync.
Currently, NopCommerce uses UseNopRequestLocalization to add all languages to SupportedCultures and SupportedUICultures.
It then creates new CultureInfo with the LanguageCulture (e.g., en-GB) as the key.
This works fine until we come to Sweden, where both Chrome and Edge send sv as the Accept-Language header and not sv-SE as NopCommerce has registered, leading to it defaulting to English.
I don't know if this is an exception for Sweden or if the same thing applies to, for example, Norway, Denmark, etc.
Changing the browser's language to English causes it to send both en and en-US as Accept-Language.
I tried changing all instances where we use LanguageCulture to determine language to UniqueSeoCode, and then everything started to work.
I don't know if this is due to some change in the browser, my computer, .net but I just wanted to share my findings.
The text was updated successfully, but these errors were encountered: