How to translate the docs
Turn an English placeholder page into a real Chinese translation without breaking structural parity.
The Chinese tree (docs/content/docs/zh/) is currently a structural mirror
of the English tree with English text as placeholders. This page is the
path to replace one page's placeholder with a real translation.
Translate the page body
- Find the page at the path identical to its English counterpart:
docs/content/docs/zh/<section>/<quadrant>/<slug>.mdx. - Translate the body into 简体中文. Keep:
- the frontmatter keys (
title,description) — translate their values; - code blocks, CLI identifiers, rule IDs, flags and file paths untranslated;
- relative
.mdxlinks exactly as they are — they resolve inside each locale automatically.
- the frontmatter keys (
- Do not add or remove sections relative to the English page; the two locales must stay structurally identical so language switching and hreflang stay meaningful.
Check the anchor links
If the English page links to a heading (…mdx#some-section), the Chinese
heading text differs, so Fumadocs' generated heading IDs differ. Either
adjust the anchor to the translated heading's slug, or link the page
without the hash.
Translate UI strings only once
Global UI strings (search, TOC, pagination, theme, language switcher, page
actions) live in one place: the zh block in
docs/lib/layout.shared.tsx. Check the keys there before translating any
UI-adjacent wording; add a key there instead of hardcoding strings in
components.
Landing page
The landing page copy is a per-locale dictionary in
docs/app/[lang]/(home)/page.tsx (en / zh objects). Translate new
landing copy in both objects in the same change.
Verify
pnpm --dir docs types:check
pnpm --dir docs build
pnpm --dir docs start # check /zh/... pages and the language switcherThe language switcher (top nav) must move from any /en/... page to the
same page under /zh/... and vice versa.
Related
- The i18n configuration: i18n layout reference
- Why two locales with explicit prefixes: i18n strategy