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
+10 -2
View File
@@ -1,5 +1,5 @@
import { formatDistance } from 'date-fns'; import { formatDistance } from 'date-fns';
import { zhCN } from 'date-fns/locale'; import { ja, zhCN, zhTW } from 'date-fns/locale';
import i18n from '@/i18n'; import i18n from '@/i18n';
export function formatDuration(seconds: number): string { export function formatDuration(seconds: number): string {
@@ -9,9 +9,17 @@ export function formatDuration(seconds: number): string {
} }
function getDateLocale() { function getDateLocale() {
if (i18n.language === 'zh-CN') return zhCN; switch (i18n.language) {
case 'ja':
return ja;
case 'zh-CN':
return zhCN;
case 'zh-TW':
return zhTW;
default:
return undefined; return undefined;
} }
}
export function formatDate(date: string | Date): string { export function formatDate(date: string | Date): string {
let dateObj: Date; let dateObj: Date;