Skip to content

Commit

Permalink
add i18n doc for custom layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Aug 15, 2023
1 parent 8984f23 commit de924cd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/get_started/en/usage/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ Then
}
```

## Layout template internationalization

Use [custom layout](./layout_template.md), if you want to internationalize, you can use `{{gettext}}` for internationalization, for example:

```html
{{gettext("Hello world")}}
```
or
```html
{{_("Hello world")}}
```

Execute `teedoc build` or `teedoc serve` will automatically generate translation files in the `layout/locales` directory, and manually edit the `po` file in `layout/locales/`.
> It will automatically generate two files `layout/i18n_babel.cfg` and `layout/i18n_locales.cfg`. The former is to set the scanned file, and the latter is to set the language to be translated. Modify it according to the situation.

> Except for using the gettext method of Jinja2 template for translation, you can also use the method of web front-end for translation, please refer to relevant information by yourself.

## Plug-in internationalization

Expand Down
19 changes: 19 additions & 0 deletions docs/get_started/zh/usage/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,25 @@ pybabel --list-locales
}
```

## 布局模板国际化

使用[自定义布局](./layout_template.md)时,如果想要国际化,可以使用`{{gettext}}`来进行国际化,比如:

```html
{{gettext("Hello world")}}
```
或者
```html
{{_("Hello world")}}
```

执行`teedoc build`或者`teedoc serve`时会在`layout/locales`目录下自动生成翻译文件,手动编辑`layout/locales/`下的`po`文件即可。
也可以手动执行 `teedoc translate` 来更新翻译文件。
> 会自动生成`layout/i18n_babel.cfg``layout/i18n_locales.cfg`两个文件,前者是设置扫描的文件,后者是设置需要翻译的语言,根据情况修改即可
> 除了使用 Jinja2 模板的 gettext 方法来翻译,你也可以用网页前端的方法来翻译,请自行查阅相关资料。


## 插件国际化

Expand Down

0 comments on commit de924cd

Please sign in to comment.