From 9c888008c92df08bd092edd67baafc887bf486ef Mon Sep 17 00:00:00 2001 From: James Pine Date: Mon, 20 Apr 2026 04:11:36 -0700 Subject: [PATCH] fix(i18n): localize relative dates for ja and zh-TW formatDate only mapped zh-CN, so history timestamps stayed in English for ja and zh-TW users even after the rest of the UI translated. Extend the switch to ja and zhTW from date-fns/locale. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/src/lib/utils/format.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/lib/utils/format.ts b/app/src/lib/utils/format.ts index d1c505d9..ba98eb0e 100644 --- a/app/src/lib/utils/format.ts +++ b/app/src/lib/utils/format.ts @@ -1,5 +1,5 @@ import { formatDistance } from 'date-fns'; -import { zhCN } from 'date-fns/locale'; +import { ja, zhCN, zhTW } from 'date-fns/locale'; import i18n from '@/i18n'; export function formatDuration(seconds: number): string { @@ -9,8 +9,16 @@ export function formatDuration(seconds: number): string { } function getDateLocale() { - if (i18n.language === 'zh-CN') return zhCN; - return undefined; + switch (i18n.language) { + case 'ja': + return ja; + case 'zh-CN': + return zhCN; + case 'zh-TW': + return zhTW; + default: + return undefined; + } } export function formatDate(date: string | Date): string {