feat: 国际化功能基础实现

This commit is contained in:
alger
2025-01-23 11:02:55 +08:00
parent 599b0251af
commit 174428b386
14 changed files with 189 additions and 17 deletions
+29
View File
@@ -0,0 +1,29 @@
export default {
common: {
play: 'Play',
pause: 'Pause',
next: 'Next',
previous: 'Previous',
volume: 'Volume',
settings: 'Settings',
search: 'Search',
loading: 'Loading...'
},
settings: {
theme: 'Theme',
language: 'Language',
about: 'About',
logout: 'Logout'
},
player: {
nowPlaying: 'Now Playing',
playlist: 'Playlist',
lyrics: 'Lyrics'
},
artist: {
songs: 'Songs',
albums: 'Albums',
mv: 'MV',
description: 'Description'
}
};
+35
View File
@@ -0,0 +1,35 @@
export default {
common: {
play: '播放',
next: '下一首',
previous: '上一首',
volume: '音量',
settings: '设置',
search: '搜索',
loading: '加载中...',
alipay: '支付宝',
wechat: '微信支付'
},
settings: {
theme: '主题',
language: '语言',
about: '关于',
logout: '退出登录'
},
player: {
nowPlaying: '正在播放',
playlist: '播放列表',
lyrics: '歌词'
},
artist: {
songs: '热门歌曲',
albums: '专辑',
mv: 'MV',
description: '简介'
},
donation: {
description: '您的捐赠将用于支持开发和维护工作,包括但不限于服务器维护、域名续费等。',
message: '留言时可留下您的邮箱或 github名称。',
refresh: '刷新列表'
}
};
+28
View File
@@ -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;
+26
View File
@@ -0,0 +1,26 @@
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 options = {
legacy: false,
locale: savedLanguage,
fallbackLocale: 'en-US',
messages: {
'zh-CN': zhCN,
'en-US': enUS
},
globalInjection: true,
silentTranslationWarn: true,
silentFallbackWarn: true
} as I18nOptions;
const i18n = createI18n(options);
export default i18n;