fix(i18n): use English runtime text and localize system UI

This commit is contained in:
Arthur Koba
2026-10-25 19:44:15 +03:00
parent ada0550571
commit 65a96670d5
289 changed files with 8092 additions and 3426 deletions
+11 -3
View File
@@ -1,5 +1,13 @@
import type { AppLocale } from './config';
import { defaultLocale } from './config';
import { defaultLocale, normalizeLocale } from './config';
// Match the language currently rendered by the provider, including the initial
// static-export render. This module also remains safe in server contexts.
export function getFormattingLocale(): AppLocale {
return typeof document === 'undefined'
? defaultLocale
: normalizeLocale(document.documentElement.lang);
}
const localeToIntl: Record<AppLocale, string> = {
'zh-CN': 'zh-CN',
@@ -8,7 +16,7 @@ const localeToIntl: Record<AppLocale, string> = {
export function formatDateTime(
dateStr: string | Date,
locale: AppLocale = defaultLocale,
locale: AppLocale = getFormattingLocale(),
timeZone = 'Asia/Shanghai',
): string {
try {
@@ -29,7 +37,7 @@ export function formatDateTime(
export function formatNumber(
value: number,
locale: AppLocale = defaultLocale,
locale: AppLocale = getFormattingLocale(),
): string {
try {
return new Intl.NumberFormat(localeToIntl[locale] ?? locale).format(value);