Skip to content

Commit c4c54f1

Browse files
committed
feat: 自动表单支持i18n
1 parent beb74d7 commit c4c54f1

File tree

6 files changed

+3142
-1
lines changed

6 files changed

+3142
-1
lines changed

web/src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import zh from 'element-plus/dist/locale/zh-cn.mjs'
1111
import en from 'element-plus/dist/locale/en.mjs'
1212
import ar from 'element-plus/dist/locale/ar.mjs'
13+
import zh_tw from 'element-plus/dist/locale/zh-tw.mjs'
1314
import {useAppStore} from "@/pinia";
1415
import { useI18n } from 'vue-i18n'
1516
@@ -20,6 +21,7 @@ defineOptions({
2021
2122
const languages = {
2223
'zh-cn': zh,
24+
'zh-TW': zh_tw,
2325
'en': en,
2426
'ar': ar
2527
}
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
<template>
2-
<fc-designer ref="designer" :config="config" height="calc(100vh - 160px)" />
2+
<fc-designer ref="designer" :config="config" :locale="languages[locale]" height="calc(100vh - 160px)" />
33
</template>
44

55
<script setup>
66
77
import {ref} from "vue";
8+
89
import FcDesigner from '@form-create/designer'
910
11+
import en from "./locale/en.js"; // 导入英文语言包
12+
import zh from "./locale/zh_cn.js"; // 导入中文语言包
13+
import zh_tw from "./locale/zh_tw.js"; // 导入中文语言包
14+
import ar from "./locale/ar.js";
15+
import {useI18n} from "vue-i18n"; // 导入中文语言包
16+
17+
const { locale } = useI18n()
18+
19+
console.log(locale.value)
20+
1021
defineOptions({
1122
name: 'FormGenerator'
1223
})
1324
25+
const languages = {
26+
'zh-cn': zh,
27+
'zh-TW': zh_tw,
28+
'en': en,
29+
'ar': ar
30+
}
31+
1432
const designer = ref(null)
1533
1634
const config = {
1735
fieldReadonly: false
1836
}
1937
38+
2039
</script>

0 commit comments

Comments
 (0)