mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
first attempt for basic date localization
This commit is contained in:
parent
c539dd1276
commit
2eaebf2bc3
@ -1,25 +1,34 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
import { en, de } from 'date-fns/locale'
|
import { enUS, de } from 'date-fns/locale'
|
||||||
import format from 'date-fns/format'
|
import format from 'date-fns/format'
|
||||||
import formatRelative from 'date-fns/formatRelative'
|
import formatRelative from 'date-fns/formatRelative'
|
||||||
import addSeconds from 'date-fns/addSeconds'
|
import addSeconds from 'date-fns/addSeconds'
|
||||||
|
|
||||||
import accounting from 'accounting'
|
import accounting from 'accounting'
|
||||||
|
|
||||||
export default ({ app }) => {
|
export default ({ app }) => {
|
||||||
|
const locales = {
|
||||||
|
en: enUS,
|
||||||
|
de: de
|
||||||
|
}
|
||||||
app.$filters = Object.assign(app.$filters || {}, {
|
app.$filters = Object.assign(app.$filters || {}, {
|
||||||
date: (value, fmt = 'dd. MMM yyyy') => {
|
date: (value, fmt = 'dd. MMM yyyy') => {
|
||||||
if (!value) return ''
|
if (!value) return ''
|
||||||
return format(new Date(value), fmt, { locale: de })
|
return format(new Date(value), fmt, {
|
||||||
|
locale: locales[app.$i18n.locale()]
|
||||||
|
})
|
||||||
},
|
},
|
||||||
dateTime: (value, fmt = 'dd. MMM yyyy HH:mm') => {
|
dateTime: (value, fmt = 'dd. MMM yyyy HH:mm') => {
|
||||||
if (!value) return ''
|
if (!value) return ''
|
||||||
return format(new Date(value), fmt, { locale: de })
|
return format(new Date(value), fmt, {
|
||||||
|
locale: locales[app.$i18n.locale()]
|
||||||
|
})
|
||||||
},
|
},
|
||||||
relativeDateTime: value => {
|
relativeDateTime: value => {
|
||||||
if (!value) return ''
|
if (!value) return ''
|
||||||
return formatRelative(new Date(value), new Date(), { locale: de })
|
return formatRelative(new Date(value), new Date(), {
|
||||||
|
locale: locales[app.$i18n.locale()]
|
||||||
|
})
|
||||||
},
|
},
|
||||||
number: (
|
number: (
|
||||||
value,
|
value,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user