fix: Implement fallback to en_GB in translation retrieval for improved language handling

This commit is contained in:
alexsparkes
2026-02-07 21:28:55 +00:00
parent bce58afa66
commit ad7963f8f5

View File

@@ -74,7 +74,16 @@ export function TranslationProvider({ children, initialLanguage, initialTranslat
if (!i18nInstance.current) {
return key;
}
return i18nInstance.current.getMessage(currentLanguage, key, optional);
try {
return i18nInstance.current.getMessage(currentLanguage, key, optional);
} catch (error) {
// Fallback to en_GB if the current language is not loaded yet
try {
return i18nInstance.current.getMessage('en_GB', key, optional);
} catch {
return key;
}
}
},
[currentLanguage],
);