Skip to content

Commit 5a6c924

Browse files
committed
fix(i18n): 修正 Copilot CR — namespace/key 与字典对齐 + html lang 跟随 locale
Footer: tagline→brand, github/discord.ariaLabel/srOnly→a11y.github/a11y.discord Hero: tagline→mission, cta→cta.access Contribute: 字典补 guideAriaLabel key(zh+en),不依赖 hero namespace layout: html lang 硬编码改为 locale 驱动,注释更新为 next-intl 描述
1 parent 04ed47f commit 5a6c924

5 files changed

Lines changed: 17 additions & 14 deletions

File tree

app/components/Footer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,36 @@ export async function Footer() {
2020
textClassName="font-serif font-black text-2xl uppercase italic text-[var(--foreground)]"
2121
/>
2222
<p className="font-body text-neutral-600 dark:text-neutral-400 mb-8 max-w-md text-justify leading-relaxed">
23-
{t("tagline")}
23+
{t("brand")}
2424
</p>
2525
<div className="flex space-x-2">
2626
<a
2727
href="https://github.com/involutionhell"
2828
target="_blank"
2929
rel="noopener noreferrer"
30-
aria-label={t("github.ariaLabel")}
31-
title={t("github.ariaLabel")}
30+
aria-label={t("a11y.github")}
31+
title={t("a11y.github")}
3232
data-umami-event="social_click"
3333
data-umami-event-platform="github"
3434
data-umami-event-location="footer"
3535
className="w-12 h-12 flex items-center justify-center border border-[var(--foreground)] hover:bg-[var(--foreground)] hover:text-[var(--background)] transition-all text-[var(--foreground)]"
3636
>
3737
<Github className="h-5 w-5" />
38-
<span className="sr-only">{t("github.srOnly")}</span>
38+
<span className="sr-only">{t("a11y.github")}</span>
3939
</a>
4040
<a
4141
href="https://discord.com/invite/6CGP73ZWbD"
4242
target="_blank"
4343
rel="noopener noreferrer"
44-
aria-label={t("discord.ariaLabel")}
45-
title={t("discord.ariaLabel")}
44+
aria-label={t("a11y.discord")}
45+
title={t("a11y.discord")}
4646
data-umami-event="social_click"
4747
data-umami-event-platform="discord"
4848
data-umami-event-location="footer"
4949
className="w-12 h-12 flex items-center justify-center border border-[var(--foreground)] hover:bg-[var(--foreground)] hover:text-[var(--background)] transition-all text-[var(--foreground)]"
5050
>
5151
<MessageCircle className="h-5 w-5" />
52-
<span className="sr-only">{t("discord.srOnly")}</span>
52+
<span className="sr-only">{t("a11y.discord")}</span>
5353
</a>
5454
</div>
5555
</div>

app/components/Hero.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function Hero() {
5757

5858
<div className="max-w-2xl">
5959
<p className="text-xl md:text-2xl font-body leading-relaxed text-justify drop-cap text-[var(--foreground)]">
60-
{t("tagline")}
60+
{t("mission")}
6161
</p>
6262

6363
<div className="mt-12">
@@ -94,7 +94,7 @@ export async function Hero() {
9494
data-umami-event-label="Access Articles"
9595
>
9696
<button className="w-full py-3 border border-[var(--background)] font-sans text-xs uppercase tracking-widest hover:bg-[var(--background)] hover:text-[var(--foreground)] transition-all cursor-pointer">
97-
{t("cta")}
97+
{t("cta.access")}
9898
</button>
9999
</Link>
100100
</div>

app/layout.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ export default async function RootLayout({
135135
const locale = cookieStore.get("locale")?.value === "en" ? "en" : "zh";
136136
const searchApi = `/search.${locale}.json`;
137137
const messages = await getMessages();
138+
const htmlLang = locale === "en" ? "en" : "zh-CN";
138139
return (
139-
<html lang="zh-CN" suppressHydrationWarning>
140+
<html lang={htmlLang} suppressHydrationWarning>
140141
<head>
141142
<link rel="preconnect" href="https://fonts.googleapis.com" />
142143
<link
@@ -213,8 +214,8 @@ export default async function RootLayout({
213214
>
214215
<div className="site-bg site-bg--stars" aria-hidden />
215216
{/*
216-
LocaleProvider 把服务端读出的 locale 注入客户端 Context
217-
客户端组件通过 useT() 拿到翻译函数,保持 SSR/CSR 一致,
217+
NextIntlClientProvider 把服务端选定的 locale 和完整 messages 传给客户端
218+
客户端组件通过 useTranslations('ns') 拿到翻译函数,保持 SSR/CSR 一致,
218219
不在客户端重新读 cookie 避免水合抖动。
219220
*/}
220221
<NextIntlClientProvider locale={locale} messages={messages}>

messages/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@
155155
"pathPreview": "Path preview: ",
156156
"pathEmpty": "(none selected)",
157157
"submit": "Continue on GitHub"
158-
}
158+
},
159+
"guideAriaLabel": "Contribution Guide"
159160
},
160161
"search": {
161162
"placeholder": "Search docs...",

messages/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@
155155
"pathPreview": "路径预览:",
156156
"pathEmpty": "(未选择)",
157157
"submit": "继续在 GitHub 新建页面"
158-
}
158+
},
159+
"guideAriaLabel": "查看投稿指南"
159160
},
160161
"search": {
161162
"placeholder": "搜索文档...",

0 commit comments

Comments
 (0)