i18n implemented

This commit is contained in:
2026-10-03 23:45:04 +02:00
parent 2ccea34bb9
commit d95ed40053
55 changed files with 2952 additions and 301 deletions
+7 -6
View File
@@ -4,18 +4,19 @@ import { useNow } from '@vueuse/core'
// damit offene Seiten ohne Reload aktuell bleiben
export function useTimeAgo() {
const now = useNow({ interval: 30_000 })
const { t } = useI18n()
return (value: string) => {
const seconds = Math.max(0, Math.floor((now.value.getTime() - new Date(value).getTime()) / 1000))
if (seconds < 60) return 'gerade eben'
if (seconds < 60) return t('timeAgo.justNow')
const minutes = Math.floor(seconds / 60)
if (minutes < 60) return `vor ${minutes} Min`
if (minutes < 60) return t('timeAgo.min', { n: minutes })
const hours = Math.floor(minutes / 60)
if (hours < 24) return `vor ${hours} Std`
if (hours < 24) return t('timeAgo.hour', { n: hours })
const days = Math.floor(hours / 24)
if (days < 30) return `vor ${days} T`
if (days < 30) return t('timeAgo.day', { n: days })
const months = Math.floor(days / 30)
if (months < 12) return `vor ${months} Mon`
return `vor ${Math.floor(months / 12)} J`
if (months < 12) return t('timeAgo.month', { n: months })
return t('timeAgo.year', { n: Math.floor(months / 12) })
}
}