X Tutup
Skip to content

Latest commit

 

History

History
124 lines (99 loc) · 3.88 KB

File metadata and controls

124 lines (99 loc) · 3.88 KB

Multi-language Documentation Organization Guide

Directory Structure

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
      ...

Route Mapping

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

Adding New Language Documentation

  1. Create a language subdirectory under the corresponding documentation directory (if it doesn't exist)

    mkdir -p docs/cheatsheet/zh
  2. 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
  3. Files will be automatically recognized and generate corresponding routes

Important Notes

  1. Filenames must match: Multi-language version filenames must match the English version, only the directory differs
  2. English version is required: All English documentation must be placed in the en/ subdirectory:
    • docs/cheatsheet/en/ - Cheatsheet pages
    • docs/builtin/en/ - Built-in functions
    • docs/modules/en/ - Module documentation
    • docs/blog/en/ - Blog posts
  3. 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.
  4. Optional translations: If a language version doesn't exist, accessing the corresponding route will display a 404
  5. File structure: Markdown file frontmatter and structure can differ, but it's recommended to keep them consistent for easier maintenance

Example

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.

Supported Languages

The following languages are currently supported:

  • en - English (default, no prefix)
  • zh - Chinese
  • es - Spanish
  • fr - French
  • de - German
  • ja - Japanese
  • ru - Russian
  • ko - Korean
  • pt - Portuguese

To add a new language, modify the locales array in vite.config.ts.

X Tutup