优化更新
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
# 国际化
|
||||
|
||||
:::tip 说明
|
||||
当前项目仅支持中文界面,ElementPlus 使用中文语言包(`zh-cn`),所有界面文本直接硬编码在组件中。如需扩展多语言支持,可基于 vue-i18n 实现。
|
||||
当前项目仅支持中文界面,AntDesign Vue 使用中文语言包(`zh-cn`),所有界面文本直接硬编码在组件中。如需扩展多语言支持,可基于 vue-i18n 实现。
|
||||
:::
|
||||
|
||||
## 当前状态
|
||||
|
||||
项目当前为中文单语言版本:
|
||||
|
||||
- ElementPlus 全局配置中文语言包:`app.use(ElementPlus, { locale: zhCn })`
|
||||
- 所有界面文本直接硬编码在组件中:`<el-button>添加岗位</el-button>`
|
||||
- AntDesign Vue 全局配置中文语言包:`app.use(Antd, { locale: zhCn })`
|
||||
- 所有界面文本直接硬编码在组件中:`<a-button>添加岗位</a-button>`
|
||||
- 后端返回的 `msg` 字段为中文:`"操作成功"`、`"岗位名称不能重复"`
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<el-button type="primary">添加岗位</el-button>
|
||||
<el-table-column label="岗位名称" prop="name" />
|
||||
<el-table-column label="创建时间" prop="createTime" />
|
||||
<a-button type="primary">添加岗位</a-button>
|
||||
<a-table-column title="岗位名称" data-index="name" />
|
||||
<a-table-column title="创建时间" data-index="createTime" />
|
||||
</template>
|
||||
```
|
||||
|
||||
@@ -65,8 +65,8 @@ export default i18n;
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<el-button type="primary">{{ $t('common.add') }}</el-button>
|
||||
<el-table-column :label="$t('position.name')" prop="name" />
|
||||
<a-button type="primary">{{ $t('common.add') }}</a-button>
|
||||
<a-table-column :title="$t('position.name')" data-index="name" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -75,13 +75,13 @@ import { useI18n } from 'vue-i18n';
|
||||
</script>
|
||||
```
|
||||
|
||||
### ElementPlus 国际化
|
||||
### AntDesign Vue 国际化
|
||||
|
||||
```typescript
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
import en from 'element-plus/es/locale/lang/en';
|
||||
import zhCN from 'ant-design-vue/es/locale/zh_CN';
|
||||
import enUS from 'ant-design-vue/es/locale/en_US';
|
||||
|
||||
app.use(ElementPlus, { locale: zhCn });
|
||||
app.use(Antd, { locale: zhCN });
|
||||
```
|
||||
|
||||
:::tip 温馨提示
|
||||
@@ -90,4 +90,4 @@ app.use(ElementPlus, { locale: zhCn });
|
||||
|
||||
## 总结
|
||||
|
||||
当前项目为中文单语言版本,ElementPlus 使用中文语言包。如需扩展多语言支持,可基于 vue-i18n 实现前端国际化,配合 ElementPlus 内置语言包和后端消息 code 实现全链路多语言。
|
||||
当前项目为中文单语言版本,AntDesign Vue 使用中文语言包。如需扩展多语言支持,可基于 vue-i18n 实现前端国际化,配合 AntDesign Vue 内置语言包和后端消息 code 实现全链路多语言。
|
||||
|
||||
Reference in New Issue
Block a user