Skip to content

Commit

Permalink
docs: 新增i18n多语言切换教程
Browse files Browse the repository at this point in the history
  • Loading branch information
amisadmin committed May 22, 2022
1 parent 98f2fbc commit 5fcf6ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/zh/docs/tutorials/basic/i18n.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 多语言

`FastAPI-Amis-Admin`的多语言支持分为前端`Amis`内部组件的多语言,以及后端常量文本的多语言.

- 系统默认内置支持语言有:`en_US`,`zh_CN`.其他语言拓展,参考[Amis多语言](https://aisuda.bce.baidu.com/amis/zh-CN/docs/extend/i18n).
- 从 0.1.1 版本开始系统默认语言为英文`en_US`.
- 可通过在项目入口文件顶部添加如下代码,进行自由切换语言.例如:

```python linenums="1" hl_lines="1 2"
from fastapi_amis_admin import i18n
i18n.set_language(language='zh_CN')

from fastapi_amis_admin.amis_admin.settings import Settings
from fastapi_amis_admin.amis_admin.site import AdminSite
from fastapi_amis_admin.amis_admin import admin
from fastapi_amis_admin.amis.components import PageSchema

# 创建AdminSite实例
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///admisadmin.db'))

# 注册管理类
@site.register_admin
class GitHubIframeAdmin(admin.IframeAdmin):
# 设置页面菜单信息
page_schema = PageSchema(label='AmisIframeAdmin', icon='fa fa-github')
# 设置跳转链接
src = 'https://github.com/amisadmin/fastapi_amis_admin'
```
1 change: 1 addition & 0 deletions docs/zh/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ nav:
- tutorials/basic/ModelAdmin.md
- tutorials/basic/ModelAction.md
- tutorials/basic/Settings.md
- tutorials/basic/i18n.md
- tutorials/basic/_more.md
- 高级教程:
- tutorials/advanced/permission.md
Expand Down

0 comments on commit 5fcf6ca

Please sign in to comment.