diff --git a/docs/get_started/en/usage/i18n.md b/docs/get_started/en/usage/i18n.md index e70b0da1..8f9cb5c2 100644 --- a/docs/get_started/en/usage/i18n.md +++ b/docs/get_started/en/usage/i18n.md @@ -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 diff --git a/docs/get_started/zh/usage/i18n.md b/docs/get_started/zh/usage/i18n.md index ae8f9b40..8c39621d 100644 --- a/docs/get_started/zh/usage/i18n.md +++ b/docs/get_started/zh/usage/i18n.md @@ -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 方法来翻译,你也可以用网页前端的方法来翻译,请自行查阅相关资料。 + + ## 插件国际化