Add a language
How-toA locale needs a config entry, strings, a content folder and a home page.
Example: add Indonesian (id). The default locale stays at /docs/; the new one lives at /id/docs/.
-
Locale. In
src/config/i18n.config.tsadd"id"tolocalesand entries tolocaleLabelsandlocaleTags. -
Strings. In
src/config/docs.config.tsaddidto everyLocalizedvalue (titles, descriptions, labels) and aui.idblock. TypeScript points at what is missing. -
Content. Copy
src/content/docs/docs/tosrc/content/docs/id/docs/and translate. Keep the same folder names; theindex.mdximports go one folder deeper (../../../../../components/...). -
Home page. Create
src/pages/id/docs/index.astro:---import DocsHome from "../../../components/docs/DocsHome.astro";---<DocsHome locale="id" /> -
Pages that exist in one language only. List their paths in
untranslatedindocs.config.ts, for example["/docs/reference"]. Links and the language menu then stay unprefixed for them.
The language menu appears automatically once there are two locales. pnpm validate:docs checks every locale folder.
Was this helpful?