refactor: 完成全站国际化改造,统一多语言支持

此提交完成了全项目的国际化适配:
1. 新增多语言翻译文件与基础配置
2. 替换所有硬编码文本为i18n调用
3. 优化语言切换与文档语言同步逻辑
4. 重构部分业务逻辑以支持动态翻译
5. 移除过时代码与硬编码配置
This commit is contained in:
2026-05-15 10:41:14 +08:00
parent ac612cb32c
commit f2c7f5e4f1
53 changed files with 2179 additions and 767 deletions

View File

@@ -2,6 +2,7 @@
import Link from "next/link";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { getDrawResults } from "@/api/draw";
import { Button } from "@/components/ui/button";
@@ -13,6 +14,7 @@ import { formatLotteryInstant } from "@/lib/player-datetime";
import type { DrawResultListItem } from "@/types/api/draw-results";
export function DrawResultsListScreen() {
const { t } = useTranslation("player");
const [items, setItems] = useState<DrawResultListItem[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [date, setDate] = useState("");
@@ -29,12 +31,12 @@ export function DrawResultsListScreen() {
});
setItems(res.items);
} catch {
setError("加载失败");
setError(t("results.loadFailed"));
setItems(null);
} finally {
setLoading(false);
}
}, [date]);
}, [date, t]);
useEffect(() => {
queueMicrotask(() => {
@@ -43,12 +45,14 @@ export function DrawResultsListScreen() {
}, [fetchList]);
return (
<PlayerPanel title="Results" subtitle="Latest draw history" eyebrow="N lotto">
<PlayerPanel title={t("results.title")} subtitle={t("results.subtitle")} eyebrow={t("brand.name")}>
<div className="space-y-4">
<JackpotResultsStrip currencyCode="NPR" />
<div className="rounded-xl border border-[#e6edf8] bg-[#f8fbff] p-3">
<p className="mb-2 text-xs font-bold text-[#32518d]">Business Date</p>
<p className="mb-2 text-xs font-bold text-[#32518d]">
{t("results.businessDate")}
</p>
<div className="flex gap-2">
<Input
type="date"
@@ -62,7 +66,7 @@ export function DrawResultsListScreen() {
className="h-10 rounded-lg bg-[#07459f] px-4 text-white hover:bg-[#063b88]"
onClick={() => void fetchList()}
>
Apply
{t("actions.apply")}
</Button>
</div>
</div>
@@ -82,12 +86,12 @@ export function DrawResultsListScreen() {
className="mt-3 bg-[#e5002c] text-white hover:bg-[#d10028]"
onClick={() => void fetchList()}
>
Retry
{t("actions.retry")}
</Button>
</div>
) : items && items.length === 0 ? (
<div className="rounded-xl border border-dashed border-[#dce7f7] bg-[#f8fbff] px-4 py-10 text-center text-sm text-slate-500">
No results yet.
{t("results.empty")}
</div>
) : (
<div className="space-y-3">
@@ -107,7 +111,7 @@ export function DrawResultsListScreen() {
</p>
</div>
<span className="shrink-0 rounded-full bg-[#f2f6ff] px-2.5 py-1 text-xs font-bold text-[#0b56b7]">
Detail
{t("results.detail")}
</span>
</div>