summaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorstuebinm2021-04-12 16:21:53 +0200
committerstuebinm2021-04-12 16:21:53 +0200
commitf02af23dd7f478a86c0522d1f4c3d924df06f3f0 (patch)
treef5431b9fbb8f8c933b823728070c89f25dc48678 /site
parent1c5b1e38820f411563efb265b18c4cba6c518074 (diff)
site: fix locale detection
(it mistakenly set the locale to undefined before)
Diffstat (limited to '')
-rw-r--r--site/i18n.js12
-rw-r--r--site/index.html2
2 files changed, 9 insertions, 5 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) {
diff --git a/site/index.html b/site/index.html
index c2ac9c9..4034787 100644
--- a/site/index.html
+++ b/site/index.html
@@ -251,7 +251,7 @@
mkElement("p", msg, "error"),
appendChildren(
mkElement("p",_("attempted path:"),"error"),
- [mkElement("tt", surveyUrl,"error")]
+ [mkElement("tt"," "+surveyUrl,"error")]
)
]);
}