aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-07-08 18:42:30 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-07-08 18:42:30 -0700
commit0ca4d441d47f1fc7d183000f318d5956a32c4f65 (patch)
treeb70856352d44185580a187cff03e10d79e325e47 /modern
parente6a115dfed5a7ffca76924e954c67205a90e46a2 (diff)
downloadtrackermap-web-0ca4d441d47f1fc7d183000f318d5956a32c4f65.tar.gz
trackermap-web-0ca4d441d47f1fc7d183000f318d5956a32c4f65.tar.bz2
trackermap-web-0ca4d441d47f1fc7d183000f318d5956a32c4f65.zip
Better language detection
Diffstat (limited to 'modern')
-rw-r--r--modern/src/common/localization.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/modern/src/common/localization.js b/modern/src/common/localization.js
index 94e089d5..8d176745 100644
--- a/modern/src/common/localization.js
+++ b/modern/src/common/localization.js
@@ -111,13 +111,19 @@ const supportedLanguages = {
const languages = window.navigator.languages !== undefined ? window.navigator.languages.slice() : [];
let language = window.navigator.userLanguage || window.navigator.language;
languages.push(language);
-languages.push(language.substr(0, 2));
+languages.push(language.substring(0, 2));
languages.push('en');
for (let i = 0; i < languages.length; i++) {
language = languages[i].replace('-', '_');
if (language in supportedLanguages) {
break;
}
+ if (language.length > 2) {
+ language = languages[i].substring(0, 2);
+ if (language in locale.languages) {
+ break;
+ }
+ }
}
const selectedLanguage = supportedLanguages[language];