📝(i18n): 重构 i18n 文档

This commit is contained in:
就眠儀式
2022-10-22 23:21:41 +08:00
parent 464b1045da
commit 6fce5acab1
7 changed files with 65 additions and 48 deletions

View File

@@ -11,28 +11,46 @@
</lay-config-provider>
</template>
```
::: describe layui-vue 内部会维护一个 vue-i18n 实例, 你无需再去创建,直接使用 useI18n() 获取即可
::: describe 在 layui-vue 内部维护了一个 i18n 实例, 你可以通过 useI18n() 方法来使用它。
:::
::: describe 你可以使用 locales 属性来扩展语言包, 用户自定义语言优先级大于组件库内部维护的语言, 即你可以扩展亦可覆盖。
::: describe 你可以使用 locales 属性来扩展语言包, 自定义语言优先级大于组件库内部维护的语言, 即扩展亦可覆盖。
:::
```vue
<template>
<lay-config-provider locale="zh_CN" :locales="locales">
<App />
{{ t('hello') }}
</lay-config-provider>
</template>
<script setup>
import { useI18n } from "@layui/layui-vue";
const { t } = useI18n();
const locales = [
'zh_CN': {
message: '你好, layui-vue'
hello: '你好',
title: '标题'
},
'en_US': {
message: 'hello, layui-vue'
hello: 'hello',
title: 'title'
}
];
</script>
```
```
::: describe 目前支持的语言列表。
:::
::: table
| 语言 | 内容 |
|-------------|-------------------------|
| zh_CN | https://gitee.com/layui/layui-vue/blob/master/package/component/src/language/locales/zh_CN.ts |
| en_US | https://gitee.com/layui/layui-vue/blob/master/package/component/src/language/locales/en_US.ts |
:::

View File

@@ -7,8 +7,7 @@ export default {
material: "物料",
},
home: {
description:
"layui - vue谐音类 UI) 是 一 套 Vue 3.0 的 桌 面 端 组 件 库.",
description: "layui - vue谐音类 UI) 是 一 套 Vue 3.0 的 桌 面 端 组 件 库.",
version: "当前版本",
changelog: "更新日志",
download: "下载量",

View File

@@ -232,15 +232,16 @@
<script>
import { provide, ref, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useAppStore } from "../store/app";
import { useI18n } from "../../../component/src/index";
import menu from "../view/utils/menus";
import { useI18n } from "vue-i18n";
import zh_CN from "../language/zh_CN.ts";
import en_US from "../language/en_US.ts";
import { useAppStore } from "../store/app";
import config from "../../../component/package.json";
export default {
setup() {
const { t } = useI18n();
const route = useRoute();
const router = useRouter();