新增翻译文件

This commit is contained in:
不做码农 2023-05-23 12:16:24 +08:00
parent 0350dca604
commit c985a7ff83
7 changed files with 21 additions and 15 deletions

View File

@ -1,10 +1,11 @@
import { createI18n } from 'vue-i18n'
// import useAppStore from '@/store/modules/app'
import { listLangByLocale } from '@/api/system/commonLang'
import jsCookie from 'js-cookie'
import { listLangByLocale } from '@/api/system/commonlang.js'
import defaultSettings from '@/settings'
import cache from '@/plugins/cache'
const language = computed(() => {
// return useAppStore().lang
return jsCookie.get('lang') || 'zh-cn'
return cache.local.get('lang') || defaultSettings.defaultLang
})
import zhCn from './lang/zh-cn.json'
@ -24,7 +25,7 @@ const i18n = createI18n({
// 全局注入 $t 函数
globalInjection: true,
fallbackLocale: 'zh-cn',
locale: language.value, //默认选择的语言
locale: language.value, //默认选择的语言
legacy: false, // 使用 Composition API 模式则需要将其设置为false
messages: {
'zh-cn': {
@ -37,17 +38,17 @@ const i18n = createI18n({
...pageLoginTw,
...pagemenuTw
},
'en': {
en: {
...en,
...pageLoginEn,
...pagemenuEn
},
}
//... 在这里添加其他语言支持
}
})
const loadLocale = () => {
listLangByLocale(language.value).then(res => {
listLangByLocale(language.value).then((res) => {
const { code, data } = res
if (code == 200) {
i18n.global.mergeLocaleMessage(language.value, data)
@ -55,4 +56,4 @@ const loadLocale = () => {
})
}
loadLocale()
export default i18n;
export default i18n

View File

@ -88,7 +88,8 @@
"identity": "Identity",
"content1": "The code is completely free and open source, easy to read and understand, and the interface is simple and beautiful, giving you one more choice and reference for your project.",
"topNav": "Top nav",
"commonFuncs": "Common Functions"
"commonFuncs": "Common Functions",
"openWatermark": "Open Watermark"
},
"common": {
"ok": "Ok",

View File

@ -88,7 +88,8 @@
"identity": "身份",
"content1": "代码完全免费开源,易读易懂、界面简洁美观,给你的项目多一种选择与参考。",
"topNav": "顶部导航",
"commonFuncs": "常用功能"
"commonFuncs": "常用功能",
"openWatermark": "开启水印"
},
"common": {
"ok": "确定",

View File

@ -88,7 +88,8 @@
"rewardUser": "打賞作者喝杯咖啡表示鼓勵",
"content1": "代碼完全免費開源,易讀易懂、界面簡潔美觀,給你的項目多一種選擇與參考。",
"topNav": "頂部導航",
"commonFuncs": "常用功能"
"commonFuncs": "常用功能",
"openWatermark": "開啟水印"
},
"common": {
"ok": "確定",

View File

@ -64,7 +64,7 @@
</span>
</div>
<div class="drawer-item">
<span>开启水印</span>
<span>{{ $t('layout.openWatermark') }}</span>
<span class="comp-style">
<el-switch v-model="showWatermark" class="drawer-switch" />
</span>

View File

@ -10,7 +10,7 @@ const useAppStore = defineStore('app', {
},
device: 'desktop',
size: cache.local.get('size') || defaultSettings.defaultSize,
lang: cache.cookie.get('lang') || defaultSettings.defaultLang
lang: cache.local.get('lang') || defaultSettings.defaultLang
}),
actions: {
toggleSideBar() {
@ -40,7 +40,7 @@ const useAppStore = defineStore('app', {
},
setLang(lang) {
this.lang = lang
cache.cookie.set('lang', lang)
cache.local.set('lang', lang)
}
}
})

View File

@ -66,7 +66,9 @@
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="Upload" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button>
<el-button type="info" plain icon="Upload" @click="handleImport" v-hasPermi="['system:user:import']">
{{ $t('btn.import') }}
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:user:export']">