Docgeni can localize your site, config fields, and component docs. Declare supported languages in .docgenirc.ts, then place files for each language using the conventions below.
Set locales (language list) and defaultLocale (fallback language):
tsexport default { locales: [ { key: 'zh-cn', name: '中文' }, { key: 'en-us', name: 'English' }, ], defaultLocale: 'zh-cn', };
key: language id used in URLs, folders, and file names (e.g. zh-cn, en-us)name: label shown in the locale switcherdefaultLocale: used when a translation is missing; must match one of the key valuesIf you only need one language, omit locales and the site is built for defaultLocale only.
Put default-language pages directly under docs, e.g. docs/guides/....
For other languages, add a folder named after the key and mirror the same tree:
docs/ ├── guides/ # default language (e.g. zh-cn) │ └── intro/ │ └── getting-started.md ├── en-us/ # English │ ├── guides/ │ │ └── intro/ │ │ └── getting-started.md │ └── index.md └── index.md
Docgeni generates top-level nav, categories, and pages per locale. Missing files for a locale may be skipped or fall back depending on the build.
Fields such as title in .docgenirc.ts are in the default language. Add a locales object and override fields per key:
tsexport default { navs: [ null, { title: 'Components', path: 'components', lib: 'alib', locales: { 'zh-cn': { title: '组件', }, }, }, ], };
The same pattern works for navs, library categories, and other config that supports locales.
Under each component folder, split docs and API by language:
button/ ├── doc/ │ ├── zh-cn.md # overview (Markdown) │ └── en-us.md └── api/ ├── zh-cn.ts # API metadata (.json, .js, etc. per apiMode) └── en-us.ts
File names must match a key from locales. Shared fields like category and order live in the default-language Front Matter only.
See Library configuration and Component docs for details.
| Content | Default language | Other languages |
|---|---|---|
| Markdown pages | docs/... |
docs/{key}/..., same structure |
| Site config (e.g. nav title) | root fields | locales.{key} on the same object |
| Component overview / API | doc/{defaultLocale}.md, etc. |
doc/{key}.md, api/{key}.* |
See Global configuration for the full locales option.