Files
Verso/services/web/frontend/js/utils/dates.ts
T
claude ae4e95312d
Build and Deploy Verso / deploy (push) Successful in 17m39s
i18n: translate hardcoded strings on project page and footer
- Card owner: "You" now goes through t('you') so it renders as
  "Vous"/"Tu"/"Du" etc. instead of always "You"
- Relative dates (fromNow): moment.locale() is now set from the app
  language so "2 days ago" becomes "il y a 2 jours" etc.
- Footer: "Built on", "Source code", "AGPL licence" are now translated
  via t() with keys added to all locale files and extracted-translations
- New keys: built_on, source_code, agpl_licence (FR/DE/IT/ES translations
  added manually)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 09:33:22 +00:00

24 lines
707 B
TypeScript

import moment from 'moment'
import getMeta from '@/utils/meta'
// Set moment's display locale to match the app language so that
// fromNow() returns "il y a 2 jours" rather than "2 days ago", etc.
const _lang = getMeta('ol-i18n')?.currentLangCode ?? 'en'
if (_lang !== 'en') {
import(`moment/locale/${_lang}`)
.then(() => { moment.locale(_lang) })
.catch(() => { /* fall back to English */ })
}
export function formatDate(date: moment.MomentInput, format?: string) {
if (!date) return 'N/A'
if (format == null) {
format = 'Do MMM YYYY, h:mm a'
}
return moment(date).format(format)
}
export function fromNowDate(date: moment.MomentInput | string) {
return moment(date).fromNow()
}