From b5b5a9eed31c218cbaf9aa74ed163a679eb2f54b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 28 Jan 2022 12:35:37 +0100 Subject: [PATCH] web/admin: only check first half of locale when detecting Signed-off-by: Jens Langhammer #2178 --- web/src/interfaces/locale.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/src/interfaces/locale.ts b/web/src/interfaces/locale.ts index a07a2794d..8f7b4d517 100644 --- a/web/src/interfaces/locale.ts +++ b/web/src/interfaces/locale.ts @@ -29,7 +29,7 @@ export const LOCALES: { locale: localeDEBUG, }, { - code: "fr_FR", + code: "fr", plurals: fr, label: t`French`, locale: localeFR_FR, @@ -50,9 +50,13 @@ LOCALES.forEach((locale) => { const DEFAULT_FALLBACK = () => "en"; export function autoDetectLanguage() { - const detected = + let detected = detect(fromUrl("lang"), fromStorage("lang"), fromNavigator(), DEFAULT_FALLBACK) || DEFAULT_FALLBACK(); + // For now we only care about the first locale part + if (detected.includes("_")) { + detected = detected.split("_")[0]; + } if (detected in i18n._messages) { console.debug(`authentik/locale: Activating detected locale '${detected}'`); i18n.activate(detected);