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 { ServerCrash, Home, RefreshCw } from "lucide-react";
import Link from "next/link";
import { useTranslation } from "react-i18next";
import { useErrorStore, ERROR_COLORS } from "@/stores/error-store";
import { Button } from "@/components/ui/button";
@@ -15,6 +16,7 @@ import { cn } from "@/lib/utils";
*/
export function ServerError(): React.ReactElement | null {
const { isServerError, serverErrorMessage, clearServerError } = useErrorStore();
const { t } = useTranslation("player");
const handleRetry = (): void => {
clearServerError();
@@ -49,7 +51,7 @@ export function ServerError(): React.ReactElement | null {
className="mb-2 text-2xl font-bold"
style={{ color: ERROR_COLORS.error }}
>
{t("serverError.title")}
</h1>
{/* 错误消息 */}
@@ -68,7 +70,7 @@ export function ServerError(): React.ReactElement | null {
style={{ borderColor: ERROR_COLORS.error, color: ERROR_COLORS.error }}
>
<RefreshCw className="size-4" />
{t("actions.retry")}
</Button>
<Link
@@ -77,13 +79,13 @@ export function ServerError(): React.ReactElement | null {
style={{ backgroundColor: ERROR_COLORS.error }}
>
<Home className="size-4" />
{t("serverError.home")}
</Link>
</div>
{/* 状态码提示 */}
<p className="mt-8 text-xs text-muted-foreground/60">
错误代码: 500 Internal Server Error
{t("serverError.code")}
</p>
</div>
</div>
@@ -95,6 +97,7 @@ export function ServerError(): React.ReactElement | null {
*/
export function ServerErrorModal(): React.ReactElement | null {
const { isServerError, serverErrorMessage, clearServerError } = useErrorStore();
const { t } = useTranslation("player");
const handleRetry = (): void => {
clearServerError();
@@ -122,7 +125,7 @@ export function ServerErrorModal(): React.ReactElement | null {
{/* 错误消息 */}
<h2 className="mb-2 text-lg font-semibold text-foreground">
{t("serverError.unavailable")}
</h2>
<p className="mb-6 text-sm text-muted-foreground">
{serverErrorMessage}
@@ -136,7 +139,7 @@ export function ServerErrorModal(): React.ReactElement | null {
onClick={handleRetry}
>
<RefreshCw className="mr-2 size-4" />
{t("actions.retry")}
</Button>
<Link
href="/hall"
@@ -144,7 +147,7 @@ export function ServerErrorModal(): React.ReactElement | null {
style={{ backgroundColor: ERROR_COLORS.error }}
>
<Home className="size-4" />
{t("serverError.home")}
</Link>
</div>
</div>