fix cannot detect the correct language in some os and browser

This commit is contained in:
MaysWind 2021-02-10 17:49:37 +08:00
parent a31c055167
commit 2ee8efe40d

View file

@ -60,6 +60,10 @@
continue; continue;
} }
if (langName.toLowerCase() === alias.toLowerCase()) {
return langName;
}
var language = ariaNgLanguages[langName]; var language = ariaNgLanguages[langName];
var aliases = language.aliases; var aliases = language.aliases;
@ -68,7 +72,7 @@
} }
for (var i = 0; i < aliases.length; i++) { for (var i = 0; i < aliases.length; i++) {
if (aliases[i] === alias) { if (aliases[i].toLowerCase() === alias.toLowerCase()) {
return langName; return langName;
} }
} }
@ -94,6 +98,19 @@
} }
} }
if (!ariaNgLanguages[browserLang] && browserLang.split('-').length > 1) { // maybe language-script-region
const langParts = browserLang.split('-');
browserLang = langParts[0] + '-' + langParts[1];
if (!ariaNgLanguages[browserLang]) {
const languageName = getLanguageNameFromAlias(browserLang);
if (languageName) {
browserLang = languageName;
}
}
}
if (!ariaNgLanguages[browserLang]) { if (!ariaNgLanguages[browserLang]) {
return ariaNgDefaultOptions.language; return ariaNgDefaultOptions.language;
} }