diff options
author | David Mehren | 2021-04-26 22:20:57 +0200 |
---|---|---|
committer | GitHub | 2021-04-26 22:20:57 +0200 |
commit | 90a8aebb711c42765450f6006a0400ed06202eb7 (patch) | |
tree | d82aa115813cf3d5be8725533219019953a696fd /public/js | |
parent | 75f1192dbe14eedfd16b8a85d8a638f9a78f11cc (diff) | |
parent | 0d943d128431f166045de53bd64575dac142d320 (diff) |
Merge pull request #1191 from hedgedoc/release/1.8.0-rc1
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/locale.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/public/js/locale.js b/public/js/locale.js index 8baa77fc..ccc1d0e4 100644 --- a/public/js/locale.js +++ b/public/js/locale.js @@ -1,7 +1,6 @@ /* eslint-env browser, jquery */ /* global Cookies */ - -const supported = ['en', 'zh-CN', 'zh-TW', 'fr', 'de', 'ja', 'es', 'ca', 'el', 'pt', 'it', 'tr', 'ru', 'nl', 'hr', 'pl', 'uk', 'hi', 'sv', 'eo', 'da', 'ko', 'id', 'sr', 'vi', 'ar', 'cs', 'sk'] +const supportedLanguages = require('../../locales/_supported.json') function detectLang () { if (Cookies.get('locale')) { @@ -13,9 +12,10 @@ function detectLang () { } const userLang = navigator.language || navigator.userLanguage const userLangCode = userLang.split('-')[0] - if (supported.includes(userLangCode)) { + const supportedLanguagesList = Object.keys(supportedLanguages) + if (supportedLanguagesList.includes(userLangCode)) { return userLangCode - } else if (supported.includes(userLang)) { + } else if (supportedLanguagesList.includes(userLang)) { return userLang } return 'en' @@ -23,6 +23,9 @@ function detectLang () { const lang = detectLang() const localeSelector = $('.ui-locale') +Object.entries(supportedLanguages).forEach(function ([isoCode, nativeName]) { + localeSelector.append(`<option value="${isoCode}">${nativeName}</option>`) +}) // the following condition is needed as the selector is only available in the intro/history page if (localeSelector.length > 0) { |