Skip to content

Commit

Permalink
fix: 🐛 Automatically apply local languages
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Jun 3, 2024
1 parent 891fe72 commit 0cc8208
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
1 change: 1 addition & 0 deletions .nvmdrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.11.1
2 changes: 0 additions & 2 deletions electron/helpers/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
7 changes: 3 additions & 4 deletions src/locales/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "取消退出",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "取消結束",
Expand Down
18 changes: 9 additions & 9 deletions src/store/preference/model/common/index.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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',
},
],
},
Expand Down

0 comments on commit 0cc8208

Please sign in to comment.