mirror of
https://github.com/mue/mue.git
synced 2026-07-18 06:24:17 +02:00
fix: Implement fallback to en_GB in translation retrieval for improved language handling
This commit is contained in:
@@ -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],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user