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
This commit is contained in:
Lenny Angst
2025-08-02 10:59:24 +02:00
parent 182c0a1840
commit de0aae3dc2
+4
View File
@@ -42,6 +42,7 @@ function getUserLocale(): string {
export async function initI18n(selectedLocale: string = getUserLocale()): Promise<void> {
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
}
}
};