Multi-language documentation is organized using a language-based directory structure as follows:
docs/
cheatsheet/
en/ # English directory
basics.md # English
built-in-functions.md
...
zh/ # Chinese directory
basics.md # Chinese version
built-in-functions.md
...
es/ # Spanish directory
basics.md
...
fr/ # French directory
de/ # German directory
ja/ # Japanese directory
ru/ # Russian directory
ko/ # Korean directory
pt/ # Portuguese directory
builtin/
en/ # English directory
abs.md # English
...
zh/
abs.md # Chinese
...
es/
...
modules/
en/ # English directory
copy-module.md # English
...
zh/
copy-module.md # Chinese
...
blog/
en/ # English directory
python-decorators.md # English
...
zh/
python-decorators.md # Chinese
...
Documents are automatically mapped to the following routes:
- English (default):
/cheatsheet/basics - Chinese:
/zh/cheatsheet/basics - Spanish:
/es/cheatsheet/basics - French:
/fr/cheatsheet/basics - German:
/de/cheatsheet/basics - Japanese:
/ja/cheatsheet/basics - Russian:
/ru/cheatsheet/basics - Korean:
/ko/cheatsheet/basics - Portuguese:
/pt/cheatsheet/basics
-
Create a language subdirectory under the corresponding documentation directory (if it doesn't exist)
mkdir -p docs/cheatsheet/zh
-
Create the corresponding translation file with the same filename as the English version
# English version: docs/cheatsheet/en/basics.md # Chinese version: docs/cheatsheet/zh/basics.md
-
Files will be automatically recognized and generate corresponding routes
- Filenames must match: Multi-language version filenames must match the English version, only the directory differs
- English version is required: All English documentation must be placed in the
en/subdirectory:docs/cheatsheet/en/- Cheatsheet pagesdocs/builtin/en/- Built-in functionsdocs/modules/en/- Module documentationdocs/blog/en/- Blog posts
- New contributions: When contributing new English documentation, place it in the corresponding
en/subdirectory. Translations for other languages are handled automatically by scripts during deployment - contributors do not need to provide i18n translations. - Optional translations: If a language version doesn't exist, accessing the corresponding route will display a 404
- File structure: Markdown file frontmatter and structure can differ, but it's recommended to keep them consistent for easier maintenance
Suppose you have the following files:
docs/cheatsheet/en/basics.md → /cheatsheet/basics
docs/cheatsheet/zh/basics.md → /zh/cheatsheet/basics
docs/cheatsheet/es/basics.md → /es/cheatsheet/basics
When accessing /zh/cheatsheet/basics, it will automatically load the docs/cheatsheet/zh/basics.md file.
The following languages are currently supported:
en- English (default, no prefix)zh- Chinesees- Spanishfr- Frenchde- Germanja- Japaneseru- Russianko- Koreanpt- Portuguese
To add a new language, modify the locales array in vite.config.ts.