feat(i18n): full Simplified Chinese localization (mechanism + UI + lesson bodies)#241
feat(i18n): full Simplified Chinese localization (mechanism + UI + lesson bodies)#241JerryC8080 wants to merge 7 commits into
Conversation
…y default)
Add an incremental i18n mechanism that defaults to English and degrades
gracefully when no locale overlay is present — zero behavior change unless
translations are added.
- site/i18n.js: shared language state (localStorage 'aiefs:lang'), per-field
fallback L(obj, field), UI string dictionary t() with {token} interpolation
tf(), and applyI18n() swapping [data-i18n] / [data-i18n-attr] nodes. A header
中/EN toggle is wired on every page and persists across pages.
- site/build.js: optionally merges sparse locale overlays (i18n/<lang>/*.json)
into data.js as *_zh fields; missing overlays fall back to English. Lesson
keywords/summary additionally reuse a co-located docs/<lang>.md when present.
Adds coverage stats; build() guarded by require.main so it is importable.
- Pages + app.js render data-driven content via L() and static UI via t(),
re-rendering on language switch.
- scripts/test_build_i18n.mjs: self-contained fixture test for the overlay /
docs extraction logic.
English source files (README/ROADMAP/glossary/en.md/outputs) stay read-only.
site/data.js is intentionally omitted — regenerated by curriculum.yml CI on merge.
Sparse zh overlays consumed by the i18n layer; absent fields fall back to English per-record, per-field. - i18n/zh/phases.json — 20 phase names + descriptions - i18n/zh/lessons.json — 468 lesson names - i18n/zh/glossary.json — 83 glossary terms (says/means) - i18n/zh/artifacts.json — 481 artifact descriptions Plus ~120 UI strings in the i18n.js dictionary (previous commit). Translated with Claude Opus 4.8 via the 'superpowers' subagent-driven workflow, following TRANSLATION_GUIDE.md (technical terms kept in English; must-translate terms standardized; bilingual QA pass for consistency).
- README.zh.md: complete zh translation, preserving all structure (19 <details> phase blocks, 541 table rows, badges, code fences, mermaid). Phase/lesson names match the i18n/zh overlay. - README.md: add a one-line [English / 简体中文] switcher under the banner (parse-safe — outside every Phase/table block build.js reads). Otherwise untouched. - Internal anchors preserved via explicit id= attributes. Translated with Claude Opus 4.8 via the superpowers workflow.
Full Chinese translations of every lesson body, one docs/zh.md alongside each docs/en.md. With these in the repo, the lesson reader's 中/EN toggle loads in-repo Chinese content directly (ZH_REPO == EN_REPO == this repo) — no external dependency — and build.js extracts keywords_zh/summary_zh from them automatically. English en.md files are untouched. Each zh.md follows TRANSLATION_GUIDE.md: a translator-note header, technical terms kept in English with first-occurrence Chinese glosses, must-translate terms standardized, and all H2/H3 section headings bilingual so readers can still search the English source. Translated with Claude Opus 4.8 via the 'superpowers' subagent-driven workflow.
|
Important Review skippedToo many files! This PR contains 300 files, which is 150 over the limit of 150. To get a review, narrow the scope: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (300)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…t-in quizzes - loadQuiz now prefers quiz.zh.json (local-first, then ZH_REPO raw) when the reader is in Chinese, falling back to the English quiz.json. Re-runs on language switch (fetchLesson is already re-invoked by the lang toggle). - getQuizQuestions() (the built-in fallback quizzes shown when a lesson has no quiz.json) now returns Chinese questions in zh mode, English otherwise. correct-answer indices and option order are identical across languages.
Chinese translations of every non-empty quiz.json across phases 02/03/10/11, one quiz.zh.json beside each quiz.json. question/options/explanation are translated; correct (answer index), stage, and option order are preserved byte-identical so scoring stays correct. English quiz.json files are untouched. Translated with Claude Opus 4.8 via the superpowers workflow, following TRANSLATION_GUIDE.md (technical terms kept in English, must-translate terms standardized).
Localize the display text inside mermaid diagrams (node labels, edge labels, subgraph titles, and sequence/state message text) across 157 docs/zh.md so the in-diagram text renders in Chinese alongside the already-translated prose. Only label text is translated — node IDs, arrows, keywords (graph/subgraph/ direction/style/classDef), \n line breaks, and style fill/stroke lines are preserved byte-identical, so every diagram still renders. ASCII punctuation that breaks mermaid parsing inside labels was swapped for fullwidth Chinese punctuation. English en.md is untouched. Translated with Claude Opus 4.8 via the superpowers workflow, following TRANSLATION_GUIDE.md.
Full Simplified Chinese localization — mechanism + UI + content + lesson bodies
First of all — thank you for this project. 🙏 Working through it has taught me a
ton about how AI actually works, end to end. While I was studying, I worked
with my code agent to translate the curriculum into Simplified Chinese as I
went, and it grew into something I'd love to give back: I'm hoping this can help
more learners in the Chinese-speaking community get into the material the same
way it helped me.
Adds an incremental internationalization layer to the site plus a complete
Simplified Chinese (
zh) translation. The mechanism defaults to English andfalls back per-field to English wherever a translation is missing, so it is
safe even with partial locales. This PR is organized as 4 reviewable commits
(mechanism → data overlay → README → lesson bodies) so each layer can be
evaluated — or accepted — independently.
Commit 1 — i18n mechanism (language-agnostic)
site/i18n.js— shared language state (localStorage['aiefs:lang']), aper-field fallback helper
L(obj, field), a UI string dictionaryt()with{token}interpolationtf(), andapplyI18n()that swaps[data-i18n]/[data-i18n-attr]nodes. A header 中/EN toggle is wiredon every page; the choice persists across pages.
site/build.js— optionally merges sparse locale overlays(
i18n/<lang>/*.json) intodata.jsas*_zh-style fields; missing overlaysfall back to English. Lesson
keywords/summaryare additionally extractedfrom a co-located
docs/<lang>.mdwhen present. Adds a coverage-statsprintout.
build()is guarded byrequire.mainso the module is importablefor tests.
app.js— render data-driven content throughL()and static UIthrough
t(), re-rendering on language switch.scripts/test_build_i18n.mjs— self-contained fixture test for theoverlay/
docsextraction logic (creates and removes its own fixture, so itpasses in any checkout regardless of which translations exist).
Commit 2 — Simplified Chinese data overlay
i18n/zh/phases.json— 20 phase names + descriptionsi18n/zh/lessons.json— 468 lesson namesi18n/zh/glossary.json— 83 glossary terms (says/means)i18n/zh/artifacts.json— 481 artifact descriptionsi18n.jsdictionary (commit 1)Commit 3 — Simplified Chinese README
README.zh.md— complete, structure-preserving translation (all 19<details>phase blocks, 541 table rows, badges, code fences, mermaid).Phase/lesson names match the
i18n/zhoverlay. Internal anchors arepreserved via explicit
id=attributes so every#sectionlink stillresolves.
README.md— gains a one-line[English · 简体中文]switcher under thebanner. This is the only change to
README.md; it sits outside everyPhase/table block
build.jsparses, so curriculum extraction is unaffected(verified: still 20 phases / 468 lessons).
Commit 4 — Simplified Chinese lesson bodies
docs/zh.md— a full Chinese translation of every lesson body,one
docs/zh.mdalongside eachdocs/en.md. Englishen.mdfiles areuntouched.
directly from this repository —
ZH_REPO == EN_REPO, no externaldependency — and
build.jsthen populateskeywords_zh/summary_zhautomatically (coverage rises to summary 468 / keywords 424).
zh.mdfollowsTRANSLATION_GUIDE.md: a translator-note header,technical terms kept in English with first-occurrence Chinese glosses,
must-translate terms standardized, and all H2/H3 headings bilingual so
readers can still search the English source.
Design principles
README.md/ROADMAP.md/glossary/terms.md/en.md/outputs) stay read-only — every translation lives in a separate file(
README.zh.md,i18n/zh/*.json,docs/zh.md), so future upstream edits tothe English sources never conflict.
never blanks out the UI.
site/data.jsis intentionally NOT included — it is a generated artifactrebuilt by the existing
curriculum.ymlCI on merge.Testing
node scripts/test_build_i18n.mjs→ PASS (self-contained).node site/build.jsruns clean both with no overlays (English-only) andwith the
zhoverlay +zh.mdbodies present; prints coverage stats(phases 20/20, lessons 468/468, glossary 83/83, artifacts 481/493).
Playwright; the choice persists across pages; no console errors;
icons/sort-arrows preserved.
Reviewing in pieces
If you'd prefer to land this incrementally, commits 1–3 are self-contained and
useful on their own (mechanism + UI + navigation/lesson-name localization +
Chinese README). Commit 4 (the 473 lesson-body translations) is the large one
and can be reviewed or deferred separately.
🤖 The Chinese translations and this i18n scaffolding were produced with
Claude Opus 4.8, orchestrated via the
superpowerssubagent-drivendevelopment workflow, following the repo's
TRANSLATION_GUIDE.md(technicalterms kept in English with first-occurrence Chinese glosses; must-translate
terms standardized; a bilingual QA pass enforced term consistency).