fix: 🐛 Automatically apply local languages

This commit is contained in:
viarotel 2024-06-03 18:12:05 +08:00
parent 891fe72588
commit 0cc8208dd1
7 changed files with 22 additions and 24 deletions

1
.nvmdrc Normal file
View File

@ -0,0 +1 @@
20.11.1

View File

@ -13,5 +13,3 @@ process.env.IS_PACKAGED = JSON.stringify(app.isPackaged)
process.env.DESKTOP_PATH = app.getPath('desktop')
process.env.CWD = process.cwd()
process.env.LOCALE = process.env.LANG?.split('.')?.[0] || 'zh_CN'

View File

@ -1,14 +1,13 @@
import { createI18n } from 'vue-i18n'
import messages from '@intlify/unplugin-vue-i18n/messages'
const locale
= window.appStore?.get('common.language')
|| window.electron?.process?.env?.LOCALE
export const locale
= window.appStore?.get('common.language') || window.navigator.language
export const i18n = createI18n({
allowComposition: false,
locale,
fallbackLocale: 'en_US',
fallbackLocale: 'en-US',
messages,
fallbackWarn: false,
missingWarn: false,

View File

@ -13,9 +13,9 @@
"common.language.name": "Language",
"common.language.placeholder": "Select language",
"common.language.zh_CN": "中文",
"common.language.zh_TW": "繁體中文",
"common.language.en_US": "English",
"common.language.zh-CN": "中文",
"common.language.zh-TW": "繁體中文",
"common.language.en-US": "English",
"close.quit": "Quit",
"close.quit.cancel": "Cancel quit",

View File

@ -13,9 +13,9 @@
"common.language.name": "语言",
"common.language.placeholder": "选择你需要的语言",
"common.language.zh_CN": "中文",
"common.language.zh_TW": "繁體中文",
"common.language.en_US": "English",
"common.language.zh-CN": "中文",
"common.language.zh-TW": "繁體中文",
"common.language.en-US": "English",
"close.quit": "退出",
"close.quit.cancel": "取消退出",

View File

@ -13,9 +13,9 @@
"common.language.name": "語言",
"common.language.placeholder": "選擇你要的語言",
"common.language.zh_CN": "中文",
"common.language.zh_TW": "繁體中文",
"common.language.en_US": "English",
"common.language.zh-CN": "中文",
"common.language.zh-TW": "繁體中文",
"common.language.en-US": "English",
"close.quit": "結束",
"close.quit.cancel": "取消結束",

View File

@ -1,8 +1,8 @@
import { locale } from '$/locales/index.js'
const { adbPath, scrcpyPath, gnirehtetPath, desktopPath }
= window?.electron?.configs || {}
const defaultLanguage = window.electron?.process?.env?.LOCALE
export default {
label: 'preferences.common.name',
field: 'common',
@ -33,20 +33,20 @@ export default {
label: 'common.language.name',
field: 'language',
type: 'LanguageSelect',
value: defaultLanguage,
value: locale,
placeholder: 'common.language.placeholder',
options: [
{
label: 'common.language.zh_CN',
value: 'zh_CN',
label: 'common.language.zh-CN',
value: 'zh-CN',
},
{
label: 'common.language.zh_TW',
value: 'zh_TW',
label: 'common.language.zh-TW',
value: 'zh-TW',
},
{
label: 'common.language.en_US',
value: 'en_US',
label: 'common.language.en-US',
value: 'en-US',
},
],
},