diff options
-rw-r--r-- | modern/src/common/localization.js | 8 | ||||
-rw-r--r-- | web/load.js | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/modern/src/common/localization.js b/modern/src/common/localization.js index 94e089d..8d17674 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]; diff --git a/web/load.js b/web/load.js index 21a69af..528b965 100644 --- a/web/load.js +++ b/web/load.js @@ -98,7 +98,7 @@ languages = window.navigator.languages !== undefined ? window.navigator.languages.slice() : []; language = window.navigator.userLanguage || window.navigator.language; languages.push(language); - languages.push(language.substr(0, 2)); + languages.push(language.substring(0, 2)); languages.push(languageDefault); for (i = 0; i < languages.length; i++) { language = languages[i].replace('-', '_'); @@ -106,6 +106,13 @@ locale.language = language; break; } + if (language.length > 2) { + language = languages[i].substring(0, 2); + if (language in locale.languages) { + locale.language = language; + break; + } + } } } |