Normalize language code comparisons
Due to using the browsers' preferred languages by default, there was a possibility that the preferred language codes did not match any extension/source language, which lead to broken filtering. While this happened, it was also possible that the preferred languages still matched properly to a language in the language filter, which caused confusion. This was the case e.g., for "en-GB" or "en-US"
This commit is contained in:
@@ -75,6 +75,10 @@ export const toUniqueLanguageCodes = (codes: string[]): string[] => {
|
||||
.map(([, languagesOfIsoCode]) => languagesOfIsoCode![0].orgCode);
|
||||
};
|
||||
|
||||
export const toComparableLanguage = (code: string): string => getLanguage(code).isoCode;
|
||||
|
||||
export const toComparableLanguages = (codes: string[]): string[] => codes.map(toComparableLanguage);
|
||||
|
||||
function defaultNativeLang(): readonly string[] {
|
||||
const preferredLanguages = toUniqueLanguageCodes([...navigator.languages]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user