Dochameleon

- 文档
- 帮助
- 博客

› 多种语言

- Configure

- Dictionary

- Docs Translation

- {lang} Parameter and Translation

For multi-language support, just create folder `website/i18n` then have language folders below it. Language code follow ISO 639-1 standard.

###
Configure

Create `i18n` folder along with `siteConfig.js`, then language folders below it.

    website/
    └── i18n/
        ├── zh/
        └── fr/

###
Dictionary

Under each language folder, create as many js file as you want, each exports an object of vocabulary map. Dochameleon will merge all objects into one big dictionary object to be used for translation.

For example:

`website/i18n/zh/blog.js`

    const blog = {
      'Why Dochameleon': '为什么Dochameleon',
      'Staging Step': '准备步骤',
      'Dochameleon.io is Live': 'Dochameleon.io上线了',
      'Pages': '网页',
      'Static Files': '静态文件',
      'Configure Source Folders': '配置源文件路径'
    };

    module.exports = blog;

###
Docs Translation

A dictionary is not enough to translate a full document. Create `docs` folder under language folder and have translated documentation. Make sure to have same document id in metadata section of the file.

For example look at here

###
{lang} Parameter and Translation

A {lang} parameter is passed down to all components for rendering. When developing your own component, make sure to get and pass down {lang} parameter as well.

When render, call `site.i18n.translate(token, lang)` to get translation.

← 分析