From a3382c2a4f30dc0ed5708fd06734b5eb57b2abfa Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 31 Oct 2022 14:35:31 +0000 Subject: [PATCH] Don't fail hard if timeago locale is not found. Closes #1646 --- src/App.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 450678f6..4db3bfb8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -67,11 +67,13 @@ 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, - ); - App.TimeAgo.addLocale(localeTime); - App.TimeAgoConfig.locale = locale; + 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)) {