From de0aae3dc2c7c911109fb94c94b719cc27327121 Mon Sep 17 00:00:00 2001 From: Lenny Angst Date: Sat, 2 Aug 2025 10:59:24 +0200 Subject: [PATCH] Make sure fallback language is always loaded Only the target language was being loaded into the client. This caused untranslated strings to be shown with their key instead of the fallback language (English). We now make sure to always load the default locale. Fixes #1047 --- materialious/src/lib/i18n/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/materialious/src/lib/i18n/index.ts b/materialious/src/lib/i18n/index.ts index e6e27826..b89bc3cf 100644 --- a/materialious/src/lib/i18n/index.ts +++ b/materialious/src/lib/i18n/index.ts @@ -42,6 +42,7 @@ function getUserLocale(): string { export async function initI18n(selectedLocale: string = getUserLocale()): Promise { const langToLoad = resources[selectedLocale] ? selectedLocale : defaultLocale; const translations = await resources[langToLoad](); + const fallbackTranslations = await resources[defaultLocale](); const options: InitOptions = { lng: langToLoad, @@ -49,6 +50,9 @@ export async function initI18n(selectedLocale: string = getUserLocale()): Promis resources: { [langToLoad]: { translation: translations.default || translations + }, + [defaultLocale]: { + translation: fallbackTranslations.default || fallbackTranslations } } };