Skip to content

feat: add Simplified Chinese localization and language switcher - #25

Merged
Teakowa merged 10 commits into
mainfrom
feat/zh-cn-localization
Sep 27, 2026
Merged

Teakowa merged 10 commits into
mainfrom
feat/zh-cn-localization

Conversation

@e54-bot

@e54-bot e54-bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Closes #24.

Summary

  • Routing: one optional [[lang=locale]] route. English stays at /, Simplified Chinese is at /zh-CN, and both are prerendered. /en does not exist (the param matcher rejects the default locale). There is no browser-language redirect.
  • Content model: copy moves from site.ts to src/lib/content/{en,zh-CN}.ts, typed by content/types.ts. Records keyed by the shared ids in site.ts plus fixed-length tuples mean a locale can't drop or add a claim without a type error. site.ts now holds only data that isn't translated: URLs, commands, repo names, support tone, and the captured terminal output.
  • Language switcher (LanguageSwitcher.svelte): a globe trigger in the desktop header opens a popover anchored to the trigger, and the mobile sheet has a list. It is built for N locales and only lists EN and 简体中文 today. Each option is a real <a> with hreflang and lang, so it works without JS, and switching keeps the current section (/#install → /zh-CN#install). It supports keyboard use (arrow keys, Home/End, Escape returns focus) and closes on an outside click or when focus leaves.
  • Metadata: hooks.server.ts sets <html lang> per prerendered page, and the layout keeps it in sync after client-side switches. Each page gets its own canonical URL, hreflang alternates (en, zh-CN, x-default), og:locale, and og:locale:alternate.
  • CJK layout (app.css): Chinese text drops the negative display tracking and gets taller leading, plus a Simplified Chinese font stack (also applied to the 简体中文 label on English pages). Chinese h1/h2 use word-break: keep-all, with \u200b hints in long headings so a line never breaks inside a word like 地图工坊. The zh theme label is 自动, which fits the segmented control and matches the platform convention.
  • Copy: the Chinese copy is written for Chinese Workshop developers, not translated word for word. Workshop terms follow the zh-CN client (地图工坊, 规则, 动作, 值, 服务器负载), and there is a space between CJK and Latin text. The English copy is tightened into plainer wording (for example, "semantic model" and "canonical emission" are gone, and "Element identities" is now "Which actions and values are used"). No capability claim was added, removed, or strengthened. The zh nav uses 语言支持 for the languages section so it isn't confused with the 语言 switcher.
  • Wayfinding fix: the header section highlight tracks every section inside the band. A section that passes through while the page re-renders no longer sticks, and the hero clears it, so a switch from the top of the page lands at the top.
  • Checks: scripts/verify-build.mjs now asserts lang, canonical, and alternates on both pages, and asserts that install commands and terminal output appear untranslated on both.
  • README "Content contract" gains a Localization section (where copy lives, the literal rules, tone, and how to add a locale).

Why

#24 asks for a Chinese homepage without changing the English default. The switcher is designed for more than two locales now, so adding one later means adding a locale, a content file, and a prerender entry, with no UI changes.

Verification

  • pnpm check: 0 errors, 0 warnings.
  • pnpm build: [verify-build] OK: installers and 2 localized pages verified.
  • Built pages served with vite preview and checked in Chrome:
    • 1440, 1024, 768, and 390 px in both locales, with no horizontal overflow (scrollWidth == clientWidth) and the header fitting at 768 px.
    • Desktop popover: opens and focuses the current language, ArrowDown+Enter switched / → /zh-CN#languages with lang=zh-CN and the zh title, Escape returns focus to the trigger, and an outside click closes it.
    • Mobile sheet: choosing 简体中文 closes the sheet, unlocks body scroll, and lands on /zh-CN.
    • Light and dark appearance.
  • Screenshots used a locally injected Noto Sans SC because the test machine has no CJK system font. Real macOS and Windows machines use PingFang SC and Microsoft YaHei from the stack.

View in Indent
Tag @indent to continue the conversation here.

Serve English at / and Simplified Chinese at /zh-CN from one optional
[[lang=locale]] route. Copy moves to typed per-locale files keyed by the
shared ids in site.ts, so both locales make the same claims; commands,
repository names, and CLI output stay literal.

- Header language menu (desktop popover, mobile sheet list) built on real
  links with hreflang/lang, keeping the current section on switch.
- Per-locale lang, canonical, hreflang alternates, and og:locale.
- CJK typography: no negative tracking, taller leading, SC font stack,
  headings wrap only between words.
- English copy tightened into plainer wording; claims unchanged.
- verify-build checks both pages' language metadata and literals.

Closes #24
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wrightkit-dev 41aa9df Commit Preview URL

Branch Preview URL
Sep 27 2026, 02:21 PM

Refine phrasing across zh-CN and en content files based on humanizer-zh principles. Eliminate translationese and awkward colloquialisms, align terminology with compiler and Workshop domain standards, and enhance fluency while strictly preserving all claims, constraints, and typographic invariants.
@indent

indent Bot commented Sep 27, 2026

Copy link
Copy Markdown

I went through b291bda. Most of it is wording only, but a few zh lines now claim more than the English, which #24 asks us to keep aligned:

  • 内置 wright Agent Skill: the skill is published separately in wrightkit/skills; it isn't built into Wright. Suggest wright Agent Skill,发布于 wrightkit/skills.
  • 新英雄…会第一时间合入 workshop-rs: "第一时间" promises speed. The English only says "without waiting for upstream releases". Suggest 会直接合入 workshop-rs,无需等待原版编译器更新发布.
  • 通过 wright-lsp 深度接入常用编辑器: the English says "any editor that speaks LSP". "深度" and "常用" change what's being claimed. Suggest 通过 wright-lsp 接入支持 LSP 的编辑器.
  • 找出性能热点: wright analyze reports control-flow hotspots, not performance measurements. Suggest 控制流热点 or just 热点.
  • 内置规则力求极低误报: "极低" is stronger than "few false positives". Suggest 力求少误报.
  • 专注于玩法设计: the English says "design". goal.md keeps gameplay/game-design judgment out of scope, so 专注于设计本身 stays closer.

Everything else reads as style. The \u200b heading hints are still in place, and CI passed on this SHA.

View session

Teakowa and others added 8 commits September 27, 2026 20:24
- Drop kickers that restate their heading (tooling, agents, languages,
  install); keep the hero audience line and the ecosystem 'open source'.
- Remove the decorative hero glow.
- Render non-goals and compatibility criteria as plain lists, not pills.
- Replace the terminal's oversized shadow with a tight one.
- Copy: drop 'not just X' / 'X, not Y' constructions; return the zh copy
  to plain spoken Chinese and bring six zh lines back in line with the
  English claims (skill not built in, no 'first-time' promise, any LSP
  editor, control-flow hotspots, few false positives, design not gameplay).

Co-authored-by: Indent <noreply@indent.com>
Eliminate remaining bureaucratic and translationese phrasing in zh-CN copy. Align with natural spoken developer language, plain phrasing conventions, and the English claims without synthetic fluff or awkward constructs.
Remove colon prompts and translation shells from zh-CN content while preserving exact meaning and workshop terminology.
- Hero: lead with the user outcome (catch bugs before loading the game).
- Tooling: drop the implementation-background lead; describe lint and
  analyze with Workshop examples; CI card says what happens in Actions.
- Agents: list what ships for coding agents (JSON output, stable codes,
  Agent Skill) and show planned features as "Coming soon" cards instead of
  the direction paragraph and five-step loop.
- Languages: plain status lines; compatibility keeps the comparison list
  and drops the policy notes.
- Trim install, ecosystem, and repo descriptions; zh-CN checked against
  the lieflat-less-ai-tone rules (no dense 、 lists).
Short headlines and one-line card bodies in the style of Apple product pages and CLI tool sites (ruff, Biome): lead with what the tool does, drop explanation. Claims unchanged; zh-CN rewritten natively, not translated.
- Hero terminal runs `wright lint rules.txt` on rules copied from the game.
- New "Copy. Save. Check." section: the in-game editor to Wright path.
- New "What it catches" section: four real findings (typo, While without
  Wait, 0.016 s loop, line of sight in a loop), each with a snippet in the
  page locale's game-client syntax. All captured from wright 0.2.40.
- "More tools" keeps analyze, inspect, editor, and CI; editor copy says
  there is no VS Code extension yet.
- Languages: one line per language; compatibility criteria removed.
- Agents: shipped capabilities plus a single "Coming soon" line.
- Remove the ecosystem section; repositories move to the footer.
- Nav: Get started / Features / Languages / Install, plus Docs (desktop
  from lg) and GitHub.
- zh code snippets keep a monospace face with a CJK fallback.
- Hero lead: lead with the value (catch errors and server-heavy code
  before players hit them) instead of skipping in-game testing.
- Hero text staggers in, terminal output lines stream in one by one,
  sections and cards rise in as they scroll into view, and each example's
  finding appears after its code.
- Hidden start state is gated on a `data-js` flag set by the boot script,
  so prerendered HTML never flashes; a 3 s CSS fallback shows everything
  if hydration fails. Reduced motion gets a short cross-fade only.
goal.md's success measure for developers is replacing manual guesswork with standard tooling (static stability warnings, diagnostics). The hero lead now opens on that instead of timing relative to players.
@Teakowa
Teakowa merged commit d47b37b into main Sep 27, 2026
2 checks passed
@Teakowa
Teakowa deleted the feat/zh-cn-localization branch September 27, 2026 14:31
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.

Add Simplified Chinese localization to wrightkit.dev

2 participants