feat: element i18n

This commit is contained in:
shaohuzhang1 2025-01-20 21:26:51 +08:00
parent 059ffc1b01
commit 0b4ae7c7a1
2 changed files with 10 additions and 2 deletions

2
ui/env.d.ts vendored
View File

@ -1,5 +1,7 @@
/// <reference types="vite/client" />
declare module 'element-plus/dist/locale/zh-cn.mjs'
declare module 'element-plus/dist/locale/en.mjs'
declare module 'element-plus/dist/locale/zh-tw.mjs'
declare module 'markdown-it-task-lists'
declare module 'markdown-it-abbr'
declare module 'markdown-it-anchor'

View File

@ -2,6 +2,8 @@ import '@/styles/index.scss'
import ElementPlus from 'element-plus'
import * as ElementPlusIcons from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import enUs from 'element-plus/dist/locale/en.mjs'
import zhTW from 'element-plus/dist/locale/zh-tw.mjs'
import { createApp } from 'vue'
import { store } from '@/stores'
import directives from '@/directives'
@ -10,7 +12,6 @@ import router from '@/router'
import Components from '@/components'
import i18n from './locales'
import { config } from 'md-editor-v3'
import screenfull from 'screenfull'
import katex from 'katex'
@ -51,8 +52,13 @@ app.use(directives)
for (const [key, component] of Object.entries(ElementPlusIcons)) {
app.component(key, component)
}
const locale_map: any = {
'zh-CN': zhCn,
'zh-Hant': zhTW,
'en-US': enUs
}
app.use(ElementPlus, {
locale: zhCn
locale: locale_map[localStorage.getItem('MaxKB-locale') || 'zh-CN']
})
app.use(router)