Fix translating dates

This commit is contained in:
kolaente 2021-07-06 16:46:45 +02:00
parent 21d31f2b40
commit 647b02e989
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -1,6 +1,6 @@
import {createDateFromString} from '@/helpers/time/createDateFromString' import {createDateFromString} from '@/helpers/time/createDateFromString'
import {format, formatDistance} from 'date-fns' import {format, formatDistance} from 'date-fns'
import { enGB, de } from 'date-fns/locale' import {enGB, de} from 'date-fns/locale'
const locales = {enGB, de} const locales = {enGB, de}
@ -30,7 +30,7 @@ export const formatDateSince = (date, $t) => {
date = createDateFromString(date) date = createDateFromString(date)
const currentDate = new Date() const currentDate = new Date()
const distance = formatDistance(date, currentDate) const distance = formatDistance(date, currentDate, {locale: locales[$t('date.locale')]})
if (date > currentDate) { if (date > currentDate) {
return $t('date.in', {date: distance}) return $t('date.in', {date: distance})