2023-05-19 18:23:25 +00:00
|
|
|
import { createI18n } from 'vue-i18n'
|
2023-05-20 14:40:17 +00:00
|
|
|
// 引入语言文件
|
2023-05-19 18:23:25 +00:00
|
|
|
import zh from './zh'
|
|
|
|
import en from './en'
|
|
|
|
|
2023-05-30 14:54:51 +00:00
|
|
|
// 读取本地存储中的语言配置
|
2023-05-30 10:59:54 +00:00
|
|
|
const localStorageString = localStorage.getItem('KUNGalgame-settings')
|
2023-05-30 14:54:51 +00:00
|
|
|
const lang = localStorageString
|
|
|
|
? JSON.parse(localStorageString).showKUNGalgameLanguage
|
|
|
|
: 'en'
|
2023-05-30 10:59:54 +00:00
|
|
|
|
2023-05-19 18:23:25 +00:00
|
|
|
const i18n = createI18n({
|
2023-05-30 14:54:51 +00:00
|
|
|
locale: lang,
|
2023-05-19 18:23:25 +00:00
|
|
|
// 支持 Vue3 composition API
|
|
|
|
legacy: false,
|
|
|
|
// 全局注册 ts 方法
|
|
|
|
globalInjection: true,
|
|
|
|
messages: {
|
|
|
|
zh,
|
|
|
|
en,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
export default i18n
|