mirror of
https://github.com/pezkuwichain/pezkuwi-extension.git
synced 2026-04-22 02:08:03 +00:00
fix(i18n): handle 'default' language by mapping to 'en'
The ui-settings LANGUAGE_DEFAULT is 'default' but no locale folder exists for it. This caused i18n to fail loading translations, breaking the entire UI including wallet creation screen (showed <unknown> instead of text). Fix normalizes 'default' language to 'en' in the i18n Backend.
This commit is contained in:
@@ -14,17 +14,24 @@ export default class Backend {
|
||||
|
||||
static type = 'backend' as const;
|
||||
|
||||
// Map 'default' language to 'en' since there's no 'default' locale folder
|
||||
private normalizeLanguage (lng: string): string {
|
||||
return lng === 'default' ? 'en' : lng;
|
||||
}
|
||||
|
||||
async read (lng: string, _namespace: string, responder: Callback): Promise<void> {
|
||||
if (languageCache[lng]) {
|
||||
return responder(null, languageCache[lng]);
|
||||
const normalizedLng = this.normalizeLanguage(lng);
|
||||
|
||||
if (languageCache[normalizedLng]) {
|
||||
return responder(null, languageCache[normalizedLng]);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
if (!loaders[lng]) {
|
||||
loaders[lng] = this.createLoader(lng);
|
||||
if (!loaders[normalizedLng]) {
|
||||
loaders[normalizedLng] = this.createLoader(normalizedLng);
|
||||
}
|
||||
|
||||
const [error, data] = await loaders[lng];
|
||||
const [error, data] = await loaders[normalizedLng];
|
||||
|
||||
return responder(error, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user