Don't fail hard if timeago locale is not found.

Closes #1646
This commit is contained in:
Kavin 2022-10-31 14:35:31 +00:00
parent e425fbeed1
commit a3382c2a4f
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -67,12 +67,14 @@ export default {
const defaultLang = await App.defaultLangage;
const locale = App.getPreferenceString("hl", defaultLang);
if (locale !== App.TimeAgoConfig.locale) {
const localeTime = await import(`../node_modules/javascript-time-ago/locale/${locale}.json`).then(
module => module.default,
);
const localeTime = await import(`../node_modules/javascript-time-ago/locale/${locale}.json`)
.catch(() => null)
.then(module => module?.default);
if (localeTime) {
App.TimeAgo.addLocale(localeTime);
App.TimeAgoConfig.locale = locale;
}
}
if (window.i18n.global.locale.value !== locale) {
if (!window.i18n.global.availableLocales.includes(locale)) {
const messages = await import(`./locales/${locale}.json`).then(module => module.default);