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) <[email protected]>
This commit is contained in:
James Pine
2026-04-20 04:11:36 -07:00
co-authored by Claude Opus 4.7
parent 07e6fb1c09
commit 9c888008c9
+11 -3
View File
@@ -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 {