mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 08:07:23 +08:00
✨ feat: 国际化 (i18n) 功能实现
This commit is contained in:
+8
-13
@@ -1,26 +1,21 @@
|
||||
import type { I18nOptions } from 'vue-i18n';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
import enUS from './lang/en-US';
|
||||
import zhCN from './lang/zh-CN';
|
||||
|
||||
// 从配置中获取保存的语言设置
|
||||
const savedLanguage =
|
||||
window?.electron?.ipcRenderer?.sendSync('get-store-value', 'set.language') || 'zh-CN';
|
||||
const messages = {
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS
|
||||
};
|
||||
|
||||
const options = {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: savedLanguage,
|
||||
locale: 'zh-CN',
|
||||
fallbackLocale: 'en-US',
|
||||
messages: {
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS
|
||||
},
|
||||
messages,
|
||||
globalInjection: true,
|
||||
silentTranslationWarn: true,
|
||||
silentFallbackWarn: true
|
||||
} as I18nOptions;
|
||||
|
||||
const i18n = createI18n(options);
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
|
||||
Reference in New Issue
Block a user