web: fix strings not being translated at all when matching browser locale not found

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

# Conflicts:
#	web/src/interfaces/locale.ts
This commit is contained in:
Jens Langhammer 2021-10-05 16:23:40 +02:00
parent aa359a032c
commit cde303e780
1 changed files with 11 additions and 2 deletions

View File

@ -11,6 +11,15 @@ i18n.load("en", localeEN);
i18n.load("debug", localeDEBUG); i18n.load("debug", localeDEBUG);
i18n.activate("en"); i18n.activate("en");
if (window.location.search.includes("debugLocale")) { const DEFAULT_FALLBACK = () => "en";
i18n.activate("debug");
const detected =
detect(fromUrl("lang"), fromStorage("lang"), fromNavigator(), DEFAULT_FALLBACK) ||
DEFAULT_FALLBACK();
if (detected in i18n._messages) {
console.debug(`authentik/locale: Activating detected locale '${detected}'`);
i18n.activate(detected);
} else {
console.debug(`authentik/locale: No locale for '${detected}', falling back to en`);
i18n.activate(DEFAULT_FALLBACK());
} }