From 0ca4d441d47f1fc7d183000f318d5956a32c4f65 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 8 Jul 2020 18:42:30 -0700 Subject: Better language detection --- modern/src/common/localization.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'modern') 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]; -- cgit v1.2.3