Skip to content

feat(ADR-0046): per-locale documentation content (doc i18n)#1848

Merged
xuyushun441-sys merged 1 commit into
mainfrom
adr0046-doc-i18n
Jun 14, 2026
Merged

feat(ADR-0046): per-locale documentation content (doc i18n)#1848
xuyushun441-sys merged 1 commit into
mainfrom
adr0046-doc-i18n

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Why

The console runs in many languages, but doc metadata (ADR-0046) shipped a single body — so a Chinese console rendered English docs. This adds per-locale documentation content, reusing the REST layer's existing Accept-Language negotiation, so docs localize on a language switch.

What

Authoring — two paths, both flat (ADR-0046's no-subdirectory rule holds):

  • Flat-file packages: sibling variant files src/docs/<name>.<locale>.md (e.g. crm_lead_guide.zh.md, ..pt-BR.md). Base <name>.md is the default + fallback.
  • TS-first code packages: inline translations on the Doc object.

Layers

  • specDocSchema.translations (locale → {label?,description?,content}) + resolveDocLocale(doc, locale): collapses to the best match (exact → primary subtag zh-CNzh → base) with per-field fallback, and strips the translations map.
  • cli/collect-docs — variant files fold into the base doc's translations; lints orphan + duplicate variants and applies the v1 MDX/image bans to variant content too.
  • rest/meta/doc (list + single) resolves the request locale from the existing Accept-Language / ?locale path, returns one localized body, and never ships translations. Doc detail bypasses the response cache so a language switch can't return a stale-locale body.
  • setup / studio — built-in overview docs now ship zh translations (inline).
  • showcaseshowcase_index.zh.md demonstrates the flat-file variant path.

No console change needed: it already sends the active UI language as Accept-Language (createAuthenticatedFetch.ts).

Verification

  • Unit: spec resolveDocLocale (exact/subtag-fallback/per-field-inherit/unknown) — 11/11; collect-docs variant fold + orphan + MDX-ban-on-variant — 16/16. All changed packages build/typecheck clean.
  • API (the exact header the console sends): GET /meta/doc/setup_overview with Accept-Language: zh → "Setup 概览" + Chinese body, translations stripped; default → English. Flat-file showcase_index variant → Chinese.
  • Browser: Chinese console (<html lang=zh>) renders the Setup doc fully in Chinese (用户与认证 / 角色与权限 / 记录可见性), inline sys_user highlighted. Screenshot captured.

🤖 Generated with Claude Code

Docs can ship localized bodies via sibling `src/docs/<name>.<locale>.md`
variant files (flat siblings; base `<name>.md` is the default + fallback),
or inline `translations` for TS-first code packages.

- spec: DocSchema.translations + resolveDocLocale (exact → primary subtag →
  base, per-field fallback, strips the map)
- cli/collect-docs: fold variants into the base doc; lint orphan/duplicate
  variants + apply the v1 MDX/image bans to variant content
- rest: /meta/doc (list + single) collapses to the request's
  Accept-Language/?locale and returns one body; doc detail bypasses cache
- setup/studio: built-in overview docs ship zh translations (inline)
- showcase: showcase_index.zh.md demonstrates the flat-file variant path

Console already sends the UI language as Accept-Language, so doc content
localizes on a language switch with no client change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 14, 2026 12:46pm

Request Review

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:system tests tooling labels Jun 14, 2026
@xuyushun441-sys
xuyushun441-sys merged commit d08551c into main Jun 14, 2026
13 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the adr0046-doc-i18n branch June 14, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants