diff --git a/.nvmdrc b/.nvmdrc new file mode 100644 index 0000000..726a201 --- /dev/null +++ b/.nvmdrc @@ -0,0 +1 @@ +20.11.1 \ No newline at end of file diff --git a/electron/helpers/process.js b/electron/helpers/process.js index 4a507c9..bddb7db 100644 --- a/electron/helpers/process.js +++ b/electron/helpers/process.js @@ -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' diff --git a/src/locales/index.js b/src/locales/index.js index af690a0..eb0281e 100644 --- a/src/locales/index.js +++ b/src/locales/index.js @@ -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, diff --git a/src/locales/languages/en_US.json b/src/locales/languages/en-US.json similarity index 99% rename from src/locales/languages/en_US.json rename to src/locales/languages/en-US.json index 5984223..24dc305 100644 --- a/src/locales/languages/en_US.json +++ b/src/locales/languages/en-US.json @@ -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", diff --git a/src/locales/languages/zh_CN.json b/src/locales/languages/zh-CN.json similarity index 99% rename from src/locales/languages/zh_CN.json rename to src/locales/languages/zh-CN.json index a9baa0a..9c11034 100644 --- a/src/locales/languages/zh_CN.json +++ b/src/locales/languages/zh-CN.json @@ -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": "取消退出", diff --git a/src/locales/languages/zh_TW.json b/src/locales/languages/zh-TW.json similarity index 99% rename from src/locales/languages/zh_TW.json rename to src/locales/languages/zh-TW.json index 2153158..5a615e4 100644 --- a/src/locales/languages/zh_TW.json +++ b/src/locales/languages/zh-TW.json @@ -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": "取消結束", diff --git a/src/store/preference/model/common/index.js b/src/store/preference/model/common/index.js index 17e764a..15426fc 100644 --- a/src/store/preference/model/common/index.js +++ b/src/store/preference/model/common/index.js @@ -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', }, ], },