新增首次运行时自动根据当前系统使用的语言设置软件显示的语言
parent
637727faa0
commit
cc5d119ba4
|
@ -10,6 +10,7 @@
|
||||||
- 新增“清热板蓝”皮肤
|
- 新增“清热板蓝”皮肤
|
||||||
- 新增软件最小化、关闭按钮位置设置,MAC版默认为左边,非MAC为右边,不想用默认的可到设置修改
|
- 新增软件最小化、关闭按钮位置设置,MAC版默认为左边,非MAC为右边,不想用默认的可到设置修改
|
||||||
- 新增快捷键设置,软件内快捷键默认开启,全局快捷键默认关闭
|
- 新增快捷键设置,软件内快捷键默认开启,全局快捷键默认关闭
|
||||||
|
- 新增首次运行时自动根据当前系统使用的语言设置软件显示的语言
|
||||||
|
|
||||||
### 优化
|
### 优化
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ const defaultSetting = {
|
||||||
},
|
},
|
||||||
windowSizeId: 2,
|
windowSizeId: 2,
|
||||||
themeId: 0,
|
themeId: 0,
|
||||||
langId: 'cns',
|
langId: null,
|
||||||
sourceId: 'kw',
|
sourceId: 'kw',
|
||||||
apiSource: 'temp',
|
apiSource: 'temp',
|
||||||
sourceNameType: 'alias',
|
sourceNameType: 'alias',
|
||||||
|
|
|
@ -16,7 +16,10 @@ const setLrcConfig = isForceSet => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (global.modules.lyricWindow) {
|
if (global.modules.lyricWindow) {
|
||||||
mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, desktopLyric)
|
mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, {
|
||||||
|
config: desktopLyric,
|
||||||
|
languageId: global.appSetting.langId,
|
||||||
|
})
|
||||||
if (isForceSet || isLock != desktopLyric.isLock) {
|
if (isForceSet || isLock != desktopLyric.isLock) {
|
||||||
isLock = desktopLyric.isLock
|
isLock = desktopLyric.isLock
|
||||||
if (desktopLyric.isLock) {
|
if (desktopLyric.isLock) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ mainOn(ipcWinLyricNames.set_lyric_config, (event, config) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
||||||
return global.appSetting.desktopLyric
|
return { config: global.appSetting.desktopLyric, languageId: global.appSetting.langId }
|
||||||
})
|
})
|
||||||
|
|
||||||
let bounds
|
let bounds
|
||||||
|
|
|
@ -105,8 +105,8 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
rendererOn(NAMES.winLyric.set_lyric_config, (event, config) => this.lrcConfig = config)
|
rendererOn(NAMES.winLyric.set_lyric_config, (event, config) => this.handleUpdateConfig(config))
|
||||||
rendererInvoke(NAMES.winLyric.get_lyric_config).then(config => this.lrcConfig = config)
|
rendererInvoke(NAMES.winLyric.get_lyric_config).then(config => this.handleUpdateConfig(config))
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('mousemove', this.handleMouseMove)
|
document.addEventListener('mousemove', this.handleMouseMove)
|
||||||
|
@ -117,6 +117,10 @@ export default {
|
||||||
document.removeEventListener('mouseup', this.handleMouseUp)
|
document.removeEventListener('mouseup', this.handleMouseUp)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleUpdateConfig({ config, languageId }) {
|
||||||
|
this.lrcConfig = config
|
||||||
|
if (this.$i18n.locale !== languageId && languageId != null) this.$i18n.locale = languageId
|
||||||
|
},
|
||||||
handleMouseDown(origin, event) {
|
handleMouseDown(origin, event) {
|
||||||
this.handleMouseUp()
|
this.handleMouseUp()
|
||||||
this.resize.origin = origin
|
this.resize.origin = origin
|
||||||
|
|
|
@ -14,8 +14,8 @@ import messages from '../../renderer/lang'
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
const i18n = window.i18n = new VueI18n({
|
const i18n = window.i18n = new VueI18n({
|
||||||
locale: 'cns',
|
locale: 'zh-cn',
|
||||||
fallbackLocale: 'cns',
|
fallbackLocale: 'zh-cn',
|
||||||
messages,
|
messages,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
新增语言时创建的语言文件夹需要与以下列表对应:
|
||||||
|
|
||||||
|
- `ar-sa` - Arabic Saudi Arabia
|
||||||
|
- `cs-cz` - Czech Czech Republic
|
||||||
|
- `da-dk` - Danish Denmark
|
||||||
|
- `de-de` - German Germany
|
||||||
|
- `el-gr` - Modern Greek Greece
|
||||||
|
- `en-au` - English Australia
|
||||||
|
- `en-gb` - English United Kingdom
|
||||||
|
- `en-ie` - English Ireland
|
||||||
|
- `en-us` - English United States
|
||||||
|
- `en-za` - English South Africa
|
||||||
|
- `es-es` - Spanish Spain
|
||||||
|
- `es-mx` - Spanish Mexico
|
||||||
|
- `fi-fi` - Finnish Finland
|
||||||
|
- `fr-ca` - French Canada
|
||||||
|
- `fr-fr` - French France
|
||||||
|
- `he-il` - Hebrew Israel
|
||||||
|
- `hi-in` - Hindi India
|
||||||
|
- `hu-hu` - Hungarian Hungary
|
||||||
|
- `id-id` - Indonesian Indonesia
|
||||||
|
- `it-it` - Italian Italy
|
||||||
|
- `ja-jp` - Japanese Japan
|
||||||
|
- `ko-kr` - Korean Republic of Korea
|
||||||
|
- `nl-be` - Dutch Belgium
|
||||||
|
- `nl-nl` - Dutch Netherlands
|
||||||
|
- `no-no` - Norwegian Norway
|
||||||
|
- `pl-pl` - Polish Poland
|
||||||
|
- `pt-br` - Portuguese Brazil
|
||||||
|
- `pt-pt` - Portuguese Portugal
|
||||||
|
- `ro-ro` - Romanian Romania
|
||||||
|
- `ru-ru` - Russian Russian Federation
|
||||||
|
- `sk-sk` - Slovak Slovakia
|
||||||
|
- `sv-se` - Swedish Sweden
|
||||||
|
- `th-th` - Thai Thailand
|
||||||
|
- `tr-tr` - Turkish Turkey
|
||||||
|
- `zh-cn` - Chinese China
|
||||||
|
- `zh-hk` - Chinese Hong Kong
|
||||||
|
- `zh-tw` - Chinese Taiwan
|
|
@ -9,7 +9,12 @@ const requireLang = require.context(
|
||||||
const messages = {}
|
const messages = {}
|
||||||
|
|
||||||
for (const file of requireLang.keys()) {
|
for (const file of requireLang.keys()) {
|
||||||
if (file === './index.js') continue
|
switch (file) {
|
||||||
|
case './index.js':
|
||||||
|
case './languages.json':
|
||||||
|
case './Readme.md':
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const path = file.replace(/(\.\/|\.json$)/g, '').split('/')
|
const path = file.replace(/(\.\/|\.json$)/g, '').split('/')
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "简体中文",
|
"name": "简体中文",
|
||||||
"locale": "cns",
|
"locale": "zh-cn",
|
||||||
"alternate": "zh-Hans",
|
"alternate": "zh-hans",
|
||||||
"country": "cn",
|
"country": "cn",
|
||||||
"fallback": true
|
"fallback": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "繁体中文",
|
"name": "繁体中文",
|
||||||
"locale": "cnt",
|
"locale": "zh-tw",
|
||||||
|
"alternate": "zh-hk",
|
||||||
"country": "cn"
|
"country": "cn"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "English",
|
"name": "English",
|
||||||
"locale": "en",
|
"locale": "en-us",
|
||||||
"country": "us"
|
"country": "us"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -14,8 +14,8 @@ import messages from '@/lang'
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
const i18n = window.i18n = new VueI18n({
|
const i18n = window.i18n = new VueI18n({
|
||||||
locale: 'cns',
|
locale: 'zh-cn',
|
||||||
fallbackLocale: 'cns',
|
fallbackLocale: 'zh-cn',
|
||||||
messages,
|
messages,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
import Store from 'electron-store'
|
import Store from 'electron-store'
|
||||||
import { windowSizeList } from '../../common/config'
|
import { windowSizeList } from '../../common/config'
|
||||||
import { version } from '../../../package.json'
|
import { version } from '../../../package.json'
|
||||||
|
import { rendererSend, NAMES } from '../../common/ipc'
|
||||||
|
import languageList from '@/lang/languages.json'
|
||||||
|
|
||||||
window.electronStore_list = new Store({
|
window.electronStore_list = new Store({
|
||||||
name: 'playList',
|
name: 'playList',
|
||||||
|
@ -15,8 +17,30 @@ let settingVersion = electronStore_config.get('version')
|
||||||
|
|
||||||
process.versions.app = version
|
process.versions.app = version
|
||||||
|
|
||||||
|
// Set language automatically
|
||||||
|
if (!window.i18n.availableLocales.includes(setting.langId)) {
|
||||||
|
let langId = null
|
||||||
|
let locale = window.navigator.language.toLocaleLowerCase()
|
||||||
|
if (window.i18n.availableLocales.includes(locale)) {
|
||||||
|
langId = locale
|
||||||
|
} else {
|
||||||
|
for (const lang of languageList) {
|
||||||
|
if (lang.alternate == locale) {
|
||||||
|
langId = lang.locale
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (langId == null) langId = 'en-us'
|
||||||
|
}
|
||||||
|
setting.langId = langId
|
||||||
|
electronStore_config.set('setting', setting)
|
||||||
|
rendererSend(NAMES.mainWindow.set_app_setting, setting)
|
||||||
|
console.log('Set lang', setting.langId)
|
||||||
|
}
|
||||||
|
|
||||||
window.i18n.locale = setting.langId
|
window.i18n.locale = setting.langId
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
themes: [
|
themes: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue