fix(i18n): overhaul i18n with [locale] routing, SSR translations, and hreflang SEO

Rewrites the i18n system introduced in PR #94 to use Next.js App Router
[locale] dynamic segments with SSR-rendered translations and proper
middleware locale routing.

- Add middleware locale detection: / rewrites to /zh-CN/ internally,
  /en and /ja pass through, /zh-CN/... redirects to bare path
- Move all 7 pages under app/[locale]/ with SSR translation injection
- Fix server→client serialization: pre-evaluate function-valued
  translations (makeSerializable) to eliminate hydration flash
- Fix language switch key flash: use hard navigation with localStorage-
  only persistence, avoiding React state update before page reload
- Add <link rel="alternate" hreflang> tags for multilingual SEO
- Fix Supabase setAll overwriting locale rewrite response
- Trim locales from 22 to 3 (zh-CN/en/ja), delete 19 incomplete files
- LLM-translate 240 firstact game preset JSONs (en + ja, landscape +
  portrait) and story titles via gemini-3.5-flash
- Delete 11 one-off migration scripts and outdated i18n docs
- Add useLocalePath hook and navigation utilities

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-18 23:16:17 +08:00
parent 941b54c3f8
commit 0a7076d5b9
301 changed files with 2447 additions and 4358 deletions
+2 -1
View File
@@ -24,6 +24,7 @@ import { selectStyle } from "./agents/styleSelector";
import { directInsertBeat, directScene } from "./director";
import { STYLE_MAP } from "@/lib/options";
import { parseJsonLoose } from "./jsonParser";
import { isValidLocale } from "@/lib/i18n/utils";
import {
FREEFORM_CLASSIFY_SYSTEM,
buildFreeformClassifyUserMessage,
@@ -65,7 +66,7 @@ export async function startSession(
styleReferenceImage: req.styleReferenceImage?.trim() || undefined,
orientation: coerceOrientation(req.orientation),
playerName: req.playerName?.trim() || undefined,
language: req.language?.trim() || undefined,
language: (req.language?.trim() && isValidLocale(req.language.trim())) ? req.language.trim() : undefined,
};
// Stage 0 — optional auto style selection. The story bible is no longer
-19
View File
@@ -24,27 +24,8 @@ import { formatStepfunCatalogForPrompt } from "@infiplot/tts-client";
// ══════════════════════════════════════════════════════════════════════
const LANG_LABELS: Record<string, string> = {
"zh-CN": "简体中文",
"zh-TW": "繁體中文",
"zh-HK": "繁體中文(香港)",
en: "English",
ja: "日本語",
ko: "한국어",
es: "Español",
fr: "Français",
de: "Deutsch",
"pt-BR": "Português (Brasil)",
pt: "Português",
ru: "Русский",
it: "Italiano",
vi: "Tiếng Việt",
th: "ภาษาไทย",
id: "Bahasa Indonesia",
tr: "Türkçe",
pl: "Polski",
nl: "Nederlands",
uk: "Українська",
hi: "हिन्दी",
cs: "Čeština",
};
/**