diff options
author | stuebinm | 2021-04-12 16:21:53 +0200 |
---|---|---|
committer | stuebinm | 2021-04-12 16:21:53 +0200 |
commit | f02af23dd7f478a86c0522d1f4c3d924df06f3f0 (patch) | |
tree | f5431b9fbb8f8c933b823728070c89f25dc48678 /site/i18n.js | |
parent | 1c5b1e38820f411563efb265b18c4cba6c518074 (diff) |
site: fix locale detection
(it mistakenly set the locale to undefined before)
Diffstat (limited to 'site/i18n.js')
-rw-r--r-- | site/i18n.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/site/i18n.js b/site/i18n.js index 5f882c5..829373e 100644 --- a/site/i18n.js +++ b/site/i18n.js @@ -54,12 +54,16 @@ let locale = "en"; // is found, it returns the key as a fallback value // (therefore, keys should themselves be understandable texts) export function _(key) { - return !(locale in langs) ? key - : !(key in langs[locale]) ? key - : langs[locale][key] + if (!(locale in langs) ? false : (key in langs[locale])) { + return langs[locale][key]; + } else { + console.log("missing translation for lang, key:", locale, key); + return key; + } } export function setLang (loc) { + console.log("set lang to", loc); locale = loc; } @@ -69,7 +73,7 @@ export function setLang (loc) { export function tryBrowserDefaultLang () { let guess = navigator.language; if (guess in langs) { - setLang(lang); + setLang(guess); } else { for (var lang of navigator.languages) { if (lang in langs) { |