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