2023-04-02 01:01:56 +08:00
|
|
|
// 自定义国际化配置
|
|
|
|
import { createI18n } from 'vue-i18n';
|
|
|
|
|
|
|
|
// 本地语言包
|
2023-04-19 11:05:30 +08:00
|
|
|
import enUSLocale from './en_US';
|
|
|
|
import zhCNLocale from './zh_CN';
|
2023-04-02 01:01:56 +08:00
|
|
|
|
|
|
|
const messages = {
|
2023-04-19 11:05:30 +08:00
|
|
|
zh_CN: {
|
|
|
|
...zhCNLocale
|
2023-04-03 00:05:09 +08:00
|
|
|
},
|
2023-04-19 11:05:30 +08:00
|
|
|
en_US: {
|
|
|
|
...enUSLocale
|
2023-04-03 00:05:09 +08:00
|
|
|
}
|
2023-04-02 01:01:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2023-04-19 14:41:15 +08:00
|
|
|
* 获取当前语言
|
2023-04-02 01:01:56 +08:00
|
|
|
* @returns zh-cn|en ...
|
|
|
|
*/
|
|
|
|
export const getLanguage = () => {
|
2023-04-19 14:41:15 +08:00
|
|
|
const language = useStorage('language', 'zh_CN');
|
|
|
|
if (language.value) {
|
|
|
|
return language.value;
|
2023-04-03 00:05:09 +08:00
|
|
|
}
|
2023-04-19 11:05:30 +08:00
|
|
|
return 'zh_CN';
|
2023-04-02 01:01:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const i18n = createI18n({
|
2023-04-03 00:05:09 +08:00
|
|
|
legacy: false,
|
|
|
|
locale: getLanguage(),
|
2023-04-18 23:36:26 +08:00
|
|
|
messages
|
2023-04-02 01:01:56 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
export default i18n;
|