所有页面-创建中英双语对照-优化翻译文档结构
This commit is contained in:
42
saiadmin-artd/src/locales/langs/README.md
Normal file
42
saiadmin-artd/src/locales/langs/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# 多语言文件说明
|
||||
|
||||
## 全局翻译(所有页面共用)
|
||||
|
||||
- `zh.json`、`en.json`:放在 `langs/` 根目录,包含菜单、公共表格操作(删除/添加/选择/操作/刷新等)、公共搜索栏(查询/重置/展开/收起、请输入/请选择、全部/启用/禁用等)、以及非页面级的文案(httpMsg、topBar、common、setting、login 等)。
|
||||
|
||||
## 页面级翻译(按路由加载)
|
||||
|
||||
路径规则:`langs/{语言}/{目录名}/{菜单名}.json`
|
||||
|
||||
示例:路由 `/dice/lottery_pool_config/index` 对应:
|
||||
|
||||
- 中文:`langs/zh/dice/lottery_pool_config.json`
|
||||
- 英文:`langs/en/dice/lottery_pool_config.json`
|
||||
|
||||
### 单文件结构
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "名称",
|
||||
"search": {
|
||||
"字段或占位 key": "中文文案"
|
||||
},
|
||||
"table": {
|
||||
"列 key": "表头中文文案"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- 顶层字段(如 `name`):该页面用到的通用字段标签,在搜索或表格中通过 `$t('page.name')` 使用。
|
||||
- `search`:搜索栏专用,如 `$t('page.search.poolType')`、`$t('page.search.placeholderName')`。
|
||||
- `table`:表格列头专用,如 `$t('page.table.poolType')`;列配置里 `label: 'page.table.xxx'` 会由表格组件自动翻译。
|
||||
|
||||
### 使用方式
|
||||
|
||||
- 搜索栏:`$t('page.name')`、`$t('page.search.xxx')`。
|
||||
- 表格列:`label: 'page.table.xxx'`(art-table 会自动对 `page.` 开头的 label 做 `$t`)。
|
||||
- 公共操作(删除、新增、操作等):继续使用 `$t('table.actions.xxx')`,来自全局 `zh.json` / `en.json`。
|
||||
|
||||
### 加载逻辑
|
||||
|
||||
- 进入某路由时,`pageLocaleLoader` 根据 path 解析出 `目录名/菜单名`,动态加载对应语言的 json 并合并到 i18n 的 `page` 命名空间;切换语言会清空缓存,下次进入或刷新后加载新语言文件。
|
||||
Reference in New Issue
Block a user