mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-28 04:12:41 +03:00
Add try/catch fallback if file fails to load
Could be the file is not there or something wrong with the connection. Still good to include this try/catch
This commit is contained in:
parent
d9bc18f557
commit
e5815686a9
1 changed files with 9 additions and 3 deletions
|
@ -33,9 +33,15 @@ export async function activateLang(lang) {
|
||||||
i18n.activate(DEFAULT_LANG);
|
i18n.activate(DEFAULT_LANG);
|
||||||
console.log('💬 ACTIVATE LANG', DEFAULT_LANG, lang);
|
console.log('💬 ACTIVATE LANG', DEFAULT_LANG, lang);
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
const { messages } = await import(`../locales/${lang}.po`);
|
const { messages } = await import(`../locales/${lang}.po`);
|
||||||
i18n.loadAndActivate({ locale: lang, messages });
|
i18n.loadAndActivate({ locale: lang, messages });
|
||||||
console.log('💬 ACTIVATE LANG', lang, messages);
|
console.log('💬 ACTIVATE LANG', lang, messages);
|
||||||
|
} catch (e) {
|
||||||
|
// Fallback to default language
|
||||||
|
i18n.activate(DEFAULT_LANG);
|
||||||
|
console.log('💬 ACTIVATE LANG', DEFAULT_LANG, lang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue