Preload the English timeago

This commit is contained in:
root
2023-03-26 15:25:40 +05:30
parent 1f7a8a3203
commit 9b1ac95320
+11 -2
View File
@@ -5,8 +5,10 @@ import * as LocaleMatcher from '@formatjs/intl-localematcher'
import store from '@/store'
import ENTranslations from '@/translations/en.json'
import ENTimeAgo from 'javascript-time-ago/locale/en.json'
Vue.use(VueI18n)
TimeAgo.addLocale(ENTimeAgo)
const messages = {
en: ENTranslations
@@ -56,6 +58,10 @@ export const TIME_AGO_EXCEPTIONS = {
'pt-BR': 'pt'
}
const TIME_AGO_LOADED = {
en: true
}
export const COUNTRY_I18N_EXCEPTIONS = {
'bn-Beng': 'bn',
'bn-Latn': 'bn',
@@ -149,8 +155,11 @@ export async function loadLocale (locale) {
async function loadFormatting (locale) {
const tal = TIME_AGO_EXCEPTIONS[locale] ?? locale
const data = await import(/* webpackChunkName: "timeago-[request]" */ `javascript-time-ago/locale/${tal}.json`)
TimeAgo.addLocale(data)
if (!TIME_AGO_LOADED[tal]) {
const data = await import(/* webpackChunkName: "timeago-[request]" */ `javascript-time-ago/locale/${tal}.json`)
TimeAgo.addLocale(data)
TIME_AGO_LOADED[tal] = true
}
const timeAgo = new TimeAgo(tal, {
polyfill: false
})