Skip to content

www: extract hardcoded UI strings into i18n translation dictionary - #142

Merged
gfargo merged 2 commits into
mainfrom
feat/www-i18n-string-extraction
Aug 10, 2026
Merged

gfargo merged 2 commits into
mainfrom
feat/www-i18n-string-extraction

Conversation

@gfargo

@gfargo gfargo commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Registers Starlight's i18n content collection (src/content/config.ts) backed by src/content/i18n/{en,zh-CN}.json
  • Extracts every hardcoded English UI string out of the custom components into Astro.locals.t() lookups: SiteTitle, Footer, HeroPlumbing (homepage hero), ScenarioBrowser, ScenarioPlayground, DiagramConflicts, DiagramPipeline, and the scenario detail page (pages/scenarios/[name].astro)
  • Client-side <script> strings (copy-button labels, commit-detail panel labels in the playground) are passed from the server via data-* attributes / a JSON island, since scripts run in the browser and can't call Astro.locals.t() directly
  • Internal links now prefix with the current locale (/zh-cn/...) where a translated route exists
  • Uses i18next pluralization (_one/_other suffixes) for counted strings like "N contracts" / "N commits"

Builds on #141 (Starlight locale scaffold). No doc content or scenario data is translated — this is UI-chrome only, per the earlier i18n audit's "moderate effort" tier.

Caveats

  • zh-CN values are a first-pass translation of short UI strings (labels, buttons, empty states) — worth a native-speaker review before treating as final, especially the longer marketing copy in the hero section
  • Scenario summaries/descriptions and the doc pages themselves remain untranslated (they're out of www/'s scope — scenario copy is generated from the main package's src/scenarios/)

Test plan

  • npm run build completes cleanly, 114 pages including all /zh-cn/... routes
  • Verified in a real browser (both en and zh-cn): nav, footer, hero, scenario browser filters + pluralized contract/line counts, playground commit-detail panel labels, copy-to-clipboard label swap (mocked clipboard API to bypass automation sandboxing), scenario detail page tabs/copy buttons
  • Confirmed English pages are visually/textually unchanged

🤖 Generated with Claude Code

gfargo and others added 2 commits August 10, 2026 19:50
Adds Starlight's i18n content collection (src/content/i18n/{en,zh-CN}.json)
and wires every custom component's hardcoded English string through
Astro.locals.t(): nav, footer, hero, the scenario browser and playground
(including client-side script strings passed in via a JSON island),
both diagrams, and the scenario detail page. Locale-aware internal links
now prefix with the current locale where a translated route exists.

zh-CN values are a first-pass machine translation of short UI strings
(labels, buttons, empty states) — good enough to unblock the routing/
rendering work, but worth a native-speaker pass before relying on it
for anything customer-facing. Scenario data/doc content is still
untranslated (out of scope here — it lives in the main package's
src/scenarios, not www/).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tionary

Continuation of 54ffc9b — the component edits (config.ts collection
registration, SiteTitle, Footer, HeroPlumbing, ScenarioBrowser,
ScenarioPlayground, DiagramConflicts, DiagramPipeline) didn't get staged
in that commit due to a shell glob error on the [name].astro path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
git-scenarios Building Building Preview Aug 10, 2026 11:51pm

@gfargo
gfargo merged commit 87b2468 into main Aug 10, 2026
17 of 18 checks passed
@gfargo
gfargo deleted the feat/www-i18n-string-extraction branch August 11, 2026 00:08

This branch was successfully deployed

1 active deployment
Preview — 43fcb990 Deployed Aug 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant