Import all locales from date-fns/locale

This commit is contained in:
Tomazed 2023-01-30 15:17:04 +01:00
parent a67213fb7b
commit db494001a2

View File

@ -2,24 +2,14 @@ import Vue from 'vue'
import Path from 'path' import Path from 'path'
import vClickOutside from 'v-click-outside' import vClickOutside from 'v-click-outside'
import { formatDistance, format, addDays, isDate, setDefaultOptions } from 'date-fns' import { formatDistance, format, addDays, isDate, setDefaultOptions } from 'date-fns'
import { de as localeDE, enUS as localeENUS, es as localeES, fr as localeFR, hr as localeHR, it as localeIT, pl as localePL, zhCN as localeZNCN } from 'date-fns/locale' import * as locale from 'date-fns/locale'
let locale = {
de: localeDE,
enUS: localeENUS,
es: localeES,
fr: localeFR,
hr: localeHR,
it: localeIT,
pl: localePL,
znCN: localeZNCN
}
Vue.directive('click-outside', vClickOutside.directive) Vue.directive('click-outside', vClickOutside.directive)
Vue.prototype.$setDateFnsLocale = (localeString) => { Vue.prototype.$setDateFnsLocale = (localeString) => {
if (!locale[localeString]) return 0 if (!locale[localeString]) return 0
return setDefaultOptions({locale: locale[localeString]}) return setDefaultOptions({ locale: locale[localeString] })
} }
Vue.prototype.$dateDistanceFromNow = (unixms) => { Vue.prototype.$dateDistanceFromNow = (unixms) => {
if (!unixms) return '' if (!unixms) return ''