chore(app): i18n sync (#15362)

This commit is contained in:
Adam 2026-02-27 09:45:00 -06:00 committed by GitHub
commit 6ef3af73df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 1096 additions and 71 deletions

View file

@ -1,4 +1,12 @@
export function getRelativeTime(dateString: string): string {
type TimeKey =
| "common.time.justNow"
| "common.time.minutesAgo.short"
| "common.time.hoursAgo.short"
| "common.time.daysAgo.short"
type Translate = (key: TimeKey, params?: Record<string, string | number>) => string
export function getRelativeTime(dateString: string, t: Translate): string {
const date = new Date(dateString)
const now = new Date()
const diffMs = now.getTime() - date.getTime()
@ -7,8 +15,8 @@ export function getRelativeTime(dateString: string): string {
const diffHours = Math.floor(diffMinutes / 60)
const diffDays = Math.floor(diffHours / 24)
if (diffSeconds < 60) return "Just now"
if (diffMinutes < 60) return `${diffMinutes}m ago`
if (diffHours < 24) return `${diffHours}h ago`
return `${diffDays}d ago`
if (diffSeconds < 60) return t("common.time.justNow")
if (diffMinutes < 60) return t("common.time.minutesAgo.short", { count: diffMinutes })
if (diffHours < 24) return t("common.time.hoursAgo.short", { count: diffHours })
return t("common.time.daysAgo.short", { count: diffDays })
}