feat(frontend): add next-intl bilingual i18n for core paths

Wire next-intl without locale routes, add zh-CN/en catalogs, language
switcher, and migrate layout/auth/settings UI copy. Document i18n rules
in AGENTS.md and keep static export builds working.
This commit is contained in:
ryan
2026-07-24 16:25:41 +08:00
parent 9c1369186f
commit 1625cfb2fb
23 changed files with 1638 additions and 355 deletions
+39
View File
@@ -0,0 +1,39 @@
import type { AppLocale } from './config';
import { defaultLocale } from './config';
const localeToIntl: Record<AppLocale, string> = {
'zh-CN': 'zh-CN',
en: 'en-US',
};
export function formatDateTime(
dateStr: string | Date,
locale: AppLocale = defaultLocale,
timeZone = 'Asia/Shanghai',
): string {
try {
const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr;
return new Intl.DateTimeFormat(localeToIntl[locale] ?? locale, {
timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hour12: false,
}).format(date);
} catch {
return String(dateStr);
}
}
export function formatNumber(
value: number,
locale: AppLocale = defaultLocale,
): string {
try {
return new Intl.NumberFormat(localeToIntl[locale] ?? locale).format(value);
} catch {
return String(value);
}
}