From 57ec87ab2452d5e72c7c21619f1d154e551a4af3 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Fri, 2 Feb 2024 12:09:49 +0100 Subject: [PATCH] Always use English and hide display language select --- frontend/src/lib/i18n/index.ts | 7 ++++++- .../src/routes/(authenticated)/user/+page.svelte | 6 +++--- .../routes/(unauthenticated)/register/+page.svelte | 12 +++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/i18n/index.ts b/frontend/src/lib/i18n/index.ts index 4a4793bf0b..0b769e4a9a 100644 --- a/frontend/src/lib/i18n/index.ts +++ b/frontend/src/lib/i18n/index.ts @@ -7,12 +7,17 @@ import { availableLocales as _availableLocales, registerAll } from '$locales'; import type { Get } from 'type-fest'; export const availableLocales = Object.freeze([..._availableLocales].sort()) as readonly [string, ...string[]]; +export function getLanguageCodeFromNavigator(): string | undefined { + // Keep the language code. Discard the country code. + return getLocaleFromNavigator()?.split('-')[0]; +} +// eslint-disable-next-line @typescript-eslint/no-unused-vars export async function loadI18n(useLocale?: string): Promise { registerAll(); init({ fallbackLocale: 'en', - initialLocale: useLocale ?? getLocaleFromNavigator()?.split('-')[0] ?? 'en', + initialLocale: /* useLocale ?? getLanguageCodeFromNavigator() ?? */ 'en', }); await waitLocale(); } diff --git a/frontend/src/routes/(authenticated)/user/+page.svelte b/frontend/src/routes/(authenticated)/user/+page.svelte index 477b90aafb..a6523f42fa 100644 --- a/frontend/src/routes/(authenticated)/user/+page.svelte +++ b/frontend/src/routes/(authenticated)/user/+page.svelte @@ -1,6 +1,6 @@