fix: 语言切换全面修复 —— 品牌层/主题首页/详情区块/404 全量 i18n(zh 矩阵 13/13)

- 站点品牌双语:每站 brandZh(品牌名/标语/hero/导航/页脚/搜索占位)由生成器写入
  站点 messages 的 zh 覆盖;SiteChrome 改为 async getTranslations 按语言渲染
- 五套主题首页接线 siteHome/hero 命名空间(新增 wire-theme-i18n.py 一次性接线脚本,
  仅处理组件函数体、hook 自动插入、hero 用 th 命名空间)
- 详情页 Use cases/Good for/FAQ/reviewCta、用例与合集索引与详情、提交页、
  对比页、Alternatives 表头与 FAQ 全部走 next-intl
- 404 双语言:locale 内走 next-intl,根级按 Accept-Language
- 修复 zh.json 中 84 处 zhXxx 旁挂键归位 + en.json 残留清理(i18n 694 键一致)
- 回归:/zh 下 13 页全中文无英文残留、无横向溢出;五站 /zh lang=zh 全部正确
This commit is contained in:
AI Directory Platform
2026-09-09 16:59:52 +00:00
parent f4f48f7293
commit 5cc4195d68
50 changed files with 4141 additions and 235 deletions
+13 -10
View File
@@ -1,6 +1,7 @@
// 自动生成:站点首页组件(源自底座 niche 形态,品牌来自 @/site/brand)
import { siteConfig } from "@/site/brand";
import { Code2, Terminal, Workflow, Layers } from "lucide-react";
import { getTranslations } from "next-intl/server";
import { ToolCard } from "@/components/tool-card";
import { LocaleLink } from "@/components/locale-link";
import { SectionHeader } from "@/kit/section";
@@ -44,6 +45,8 @@ const footerGroups = [
];
async function SiteHome({ locale }: { locale: string }) {
const t = await getTranslations("siteHome");
const th = await getTranslations("hero");
const data = await getHomeDataSafe(6);
return (
@@ -65,10 +68,10 @@ async function SiteHome({ locale }: { locale: string }) {
</p>
<p className="flex items-center gap-2 text-foreground">
<Terminal className="h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400" />
{siteConfig.brand.headline}
{th("title")}
</p>
<p className="text-xs leading-relaxed text-muted-foreground">
{siteConfig.brand.subheadline}
{th("description")}
</p>
<p className="pt-2">
<LocaleLink
@@ -88,10 +91,10 @@ async function SiteHome({ locale }: { locale: string }) {
{data.useCases.length > 0 && (
<section>
<SectionHeader
title="Ship faster with AI"
subtitle="Pick your workflow — we ranked the tools for it"
title={t("shipTitle")}
subtitle={t("shipSubtitle")}
viewAllHref="/ai-tools-for"
viewAllLabel="All use cases"
viewAllLabel={t("useCasesViewAll")}
/>
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
{data.useCases.slice(0, 6).map((uc) => (
@@ -119,7 +122,7 @@ async function SiteHome({ locale }: { locale: string }) {
{data.trending.length > 0 && (
<section>
<SectionHeader
title="Most upvoted this week"
title={t("upvotedTitle")}
viewAllHref="/rankings?board=trending"
/>
<div className="grid gap-3 md:grid-cols-2">
@@ -139,10 +142,10 @@ async function SiteHome({ locale }: { locale: string }) {
{data.collections.length > 0 && (
<section>
<SectionHeader
title="Workflows & stacks"
subtitle="Batteries-included tool stacks for common dev tasks"
title={t("workflowsTitle")}
subtitle={t("workflowsSubtitle")}
viewAllHref="/best"
viewAllLabel="All workflows"
viewAllLabel={t("workflowsViewAll")}
/>
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
{data.collections.slice(0, 3).map((col) => (
@@ -167,7 +170,7 @@ async function SiteHome({ locale }: { locale: string }) {
{/* Categories */}
{data.categories.length > 0 && (
<section>
<SectionHeader title="Browse by category" viewAllHref="/tools" />
<SectionHeader title={t("categoriesTitle")} viewAllHref="/tools" />
<div className="flex flex-wrap gap-2">
{data.categories.slice(0, 14).map((cat) => (
<LocaleLink