From d44aa0af82fb9ff02bb58f6656d7cb3bd1ecbf29 Mon Sep 17 00:00:00 2001
From: liuyonghe0111 <1763195287@qq.com>
Date: Tue, 23 Dec 2025 15:20:36 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E5=99=A8=E7=BB=84=E4=BB=B6=E5=9B=BD=E9=99=85=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
next.config.ts | 5 ++-
src/app/(main)/character/[id]/page.tsx | 8 +++--
src/{locales/en.ts => i18n/en-US.ts} | 5 +++
src/{locales/zh.ts => i18n/zh-CN.ts} | 5 +++
.../BasicLayout/components/LocaleSwitch.tsx | 6 ++--
src/layout/Providers/IntlProvider.tsx | 17 +++++-----
src/lib/i18n.ts | 20 ++++++++++++
src/proxy.ts | 32 +++++++------------
8 files changed, 63 insertions(+), 35 deletions(-)
rename src/{locales/en.ts => i18n/en-US.ts} (98%)
rename src/{locales/zh.ts => i18n/zh-CN.ts} (98%)
create mode 100644 src/lib/i18n.ts
diff --git a/next.config.ts b/next.config.ts
index f4ed92f..24f61e8 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,4 +1,7 @@
import type { NextConfig } from 'next';
+import createNextIntlPlugin from 'next-intl/plugin';
+// 指定 i18n 配置文件路径,让 next-intl 知道支持的语言
+const withNextIntl = createNextIntlPlugin('./src/lib/i18n.ts');
const nextConfig: NextConfig = {
/* config options here */
@@ -32,4 +35,4 @@ const nextConfig: NextConfig = {
},
};
-export default nextConfig;
+export default withNextIntl(nextConfig);
diff --git a/src/app/(main)/character/[id]/page.tsx b/src/app/(main)/character/[id]/page.tsx
index 8438848..fd5a643 100644
--- a/src/app/(main)/character/[id]/page.tsx
+++ b/src/app/(main)/character/[id]/page.tsx
@@ -4,10 +4,12 @@ import { Chip } from '@/components/ui/chip';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { IconButton } from '@/components/ui/button';
import Link from 'next/link';
+import { getTranslations } from 'next-intl/server';
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const character = await fetchCharacter(id);
+ const t = await getTranslations('character');
return (
@@ -45,7 +47,7 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
9.9k
- Liked
+ {t('liked')}
@@ -57,11 +59,11 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
/>
123456
-
Hot
+
{t('hot')}
-
Introduction
+
{t('introduction')}
{character?.description}
diff --git a/src/locales/en.ts b/src/i18n/en-US.ts
similarity index 98%
rename from src/locales/en.ts
rename to src/i18n/en-US.ts
index eedc35b..3985ea7 100644
--- a/src/locales/en.ts
+++ b/src/i18n/en-US.ts
@@ -22,6 +22,11 @@ export default {
check_in: 'Check-in',
check_in_desc: 'Daily Free crush coinsh',
},
+ character: {
+ liked: 'Liked',
+ hot: 'Hot',
+ introduction: 'Introduction',
+ },
chat: {
chats: 'Chats',
drawer: {
diff --git a/src/locales/zh.ts b/src/i18n/zh-CN.ts
similarity index 98%
rename from src/locales/zh.ts
rename to src/i18n/zh-CN.ts
index 97d6a38..9dec178 100644
--- a/src/locales/zh.ts
+++ b/src/i18n/zh-CN.ts
@@ -22,6 +22,11 @@ export default {
check_in: '签到',
check_in_desc: '每日签到,免费获取金币',
},
+ character: {
+ liked: '喜欢',
+ hot: '热度',
+ introduction: '人物简介',
+ },
chat: {
chats: '聊天',
drawer: {
diff --git a/src/layout/BasicLayout/components/LocaleSwitch.tsx b/src/layout/BasicLayout/components/LocaleSwitch.tsx
index 65be262..f3f38b1 100644
--- a/src/layout/BasicLayout/components/LocaleSwitch.tsx
+++ b/src/layout/BasicLayout/components/LocaleSwitch.tsx
@@ -13,13 +13,13 @@ export default function LocaleSwitch() {
const { locale, setLocale } = useLocale();
return (
-