diff options
Diffstat (limited to '')
-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) { |