Internationalization

GemBook makes it easy to support multiple languages on the documentation site. The language code is displayed in the URL path: /{lang}/path. Paths without a language code (e.g. / or old links) redirect to the language preferred by the browser, or the default language.

Enable internationalization

  1. Use --i18n or i18n to enable internationalization
  2. Move the document to a folder named with the language code, for example:
docs/
├── en
│   ├── guide
│   │   ├── README.md
│   │   └── installation.md
│   ├── 003-about.md
│   └── README.md
└── zh
    ├── guide
    │   ├── README.md
    │   └── installation.md
    └── README.md

The default language is en, or the first language if there is no en, use fallbackLanguage to specify it.

For language code support, please check here. The text of the website itself (e.g. "Edit this page") supports English and Chinese, other languages use English.

Untranslated documents

A document that only contains a title (frontmatter and # Title) is untranslated, the document of the same path in the default language is machine translated when building and a notice is displayed; if the translation fails, the original document is displayed.

Directory name localization

By default, the directory name will be rendered directly in the sidebar. If you need to localize the directory name, there are two ways:

  • Modify the directory name, for example, change docs/zh/guide to docs/zh/002-指南
  • Add the file config.yml in the directory.