mirror of
https://gitee.com/yiming_chang/vue-pure-admin.git
synced 2024-12-05 12:47:53 +08:00
fix: vxe-table i18n
This commit is contained in:
parent
51d08e4b82
commit
a7576f6971
@ -3,9 +3,6 @@ import { App, WritableComputedRef } from "vue";
|
||||
import { storageLocal } from "/@/utils/storage";
|
||||
import { type I18n, createI18n } from "vue-i18n";
|
||||
|
||||
// vxe-table组件国际化
|
||||
import zhVxeTable from "vxe-table/lib/locale/lang/zh-CN";
|
||||
import enVxeTable from "vxe-table/lib/locale/lang/en-US";
|
||||
// element-plus国际化
|
||||
import enLocale from "element-plus/lib/locale/lang/en";
|
||||
import zhLocale from "element-plus/lib/locale/lang/zh-cn";
|
||||
@ -24,12 +21,10 @@ function siphonI18n(prefix = "zh-CN") {
|
||||
export const localesConfigs = {
|
||||
zh: {
|
||||
...siphonI18n("zh-CN"),
|
||||
...zhVxeTable,
|
||||
...zhLocale
|
||||
},
|
||||
en: {
|
||||
...siphonI18n("en"),
|
||||
...enVxeTable,
|
||||
...enLocale
|
||||
}
|
||||
};
|
||||
|
@ -1,11 +1,14 @@
|
||||
import "xe-utils";
|
||||
import { App } from "vue";
|
||||
import XEUtils from "xe-utils";
|
||||
import { App, unref } from "vue";
|
||||
import { i18n } from "/@/plugins/i18n";
|
||||
import "font-awesome/css/font-awesome.min.css";
|
||||
import zh from "vxe-table/lib/locale/lang/zh-CN";
|
||||
import en from "vxe-table/lib/locale/lang/en-US";
|
||||
|
||||
import {
|
||||
// 核心
|
||||
VXETable,
|
||||
|
||||
// 表格功能
|
||||
Header,
|
||||
Footer,
|
||||
@ -16,7 +19,6 @@ import {
|
||||
Export,
|
||||
Keyboard,
|
||||
Validator,
|
||||
|
||||
// 可选组件
|
||||
Column,
|
||||
Colgroup,
|
||||
@ -42,7 +44,6 @@ import {
|
||||
Modal,
|
||||
List,
|
||||
Pulldown,
|
||||
|
||||
// 表格
|
||||
Table
|
||||
} from "vxe-table";
|
||||
@ -61,19 +62,10 @@ VXETable.setup({
|
||||
input: {
|
||||
clearable: true
|
||||
},
|
||||
// 对组件内置的提示语进行国际化翻译
|
||||
// @ts-ignore
|
||||
i18n: (key, args) => i18n.global.t(key, args),
|
||||
// 可选,对参数中的列头、校验提示..等进行自动翻译(只对支持国际化的有效)
|
||||
translate(key, args) {
|
||||
// 例如,只翻译 "buttons." 开头的键值
|
||||
if (key && key.indexOf("buttons.") > -1) {
|
||||
return i18n.global.t(key, args);
|
||||
}
|
||||
if (key && key.indexOf("el.") > -1) {
|
||||
return i18n.global.t(key, args);
|
||||
}
|
||||
return key;
|
||||
i18n: (key, args) => {
|
||||
return unref(i18n.global.locale) === "zh"
|
||||
? XEUtils.toFormatString(XEUtils.get(zh, key), args)
|
||||
: XEUtils.toFormatString(XEUtils.get(en, key), args);
|
||||
}
|
||||
});
|
||||
|
||||
@ -88,7 +80,6 @@ export function useTable(app: App) {
|
||||
.use(Export)
|
||||
.use(Keyboard)
|
||||
.use(Validator)
|
||||
|
||||
// 可选组件
|
||||
.use(Column)
|
||||
.use(Colgroup)
|
||||
|
Loading…
Reference in New Issue
Block a user