mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 16:27:23 +08:00
✨ feat: 国际化功能基础实现
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { I18nOptions } from 'vue-i18n';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
import { getStore } from '../main/modules/config';
|
||||
import enUS from './lang/en-US';
|
||||
import zhCN from './lang/zh-CN';
|
||||
|
||||
// 从配置中获取保存的语言设置
|
||||
const store = getStore();
|
||||
const savedLanguage = (store?.get('set.language') as string) || 'zh-CN';
|
||||
|
||||
const options = {
|
||||
legacy: false,
|
||||
locale: savedLanguage,
|
||||
fallbackLocale: 'en-US',
|
||||
messages: {
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS
|
||||
},
|
||||
silentTranslationWarn: true,
|
||||
silentFallbackWarn: true
|
||||
} as I18nOptions;
|
||||
|
||||
const i18n = createI18n(options);
|
||||
|
||||
export const $t: typeof i18n.global.t = i18n.global.t;
|
||||
|
||||
export default i18n;
|
||||
Reference in New Issue
Block a user