mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-24 02:05:39 +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);
|
||||
console.log('💬 ACTIVATE LANG', DEFAULT_LANG, lang);
|
||||
} else {
|
||||
const { messages } = await import(`../locales/${lang}.po`);
|
||||
i18n.loadAndActivate({ locale: lang, messages });
|
||||
console.log('💬 ACTIVATE LANG', lang, messages);
|
||||
try {
|
||||
const { messages } = await import(`../locales/${lang}.po`);
|
||||
i18n.loadAndActivate({ locale: 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