From 1936ccfedc712eb99ae64dbc91b2e12b4c3e095e Mon Sep 17 00:00:00 2001 From: PiEgg Date: Sun, 20 Feb 2022 21:30:22 +0800 Subject: [PATCH] :sparkles: Feature: add i18n for en --- src/main.ts | 7 +- src/main/apis/app/window/windowList.ts | 18 ++- src/main/events/ipcList.ts | 9 +- src/main/events/picgoCoreIPC.ts | 8 +- src/main/lifeCycle/index.ts | 2 + src/main/utils/handleI18n.ts | 6 + src/renderer/pages/PicGoSetting.vue | 43 ++++- src/renderer/utils/beforeOpen.ts | 10 ++ src/renderer/utils/mainMixin.ts | 12 +- src/universal/events/constants.ts | 2 + src/universal/i18n/en.ts | 216 +++++++++++++++++++++++++ src/universal/i18n/index.ts | 12 +- src/universal/i18n/zh-CN.ts | 4 +- src/universal/types/extra-vue.d.ts | 2 + src/universal/types/view.d.ts | 1 + 15 files changed, 333 insertions(+), 19 deletions(-) create mode 100644 src/main/utils/handleI18n.ts create mode 100644 src/renderer/utils/beforeOpen.ts create mode 100644 src/universal/i18n/en.ts diff --git a/src/main.ts b/src/main.ts index 0b7214c..19d719d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,10 +10,14 @@ import mainMixin from './renderer/utils/mainMixin' import bus from '@/utils/bus' import { initTalkingData } from './renderer/utils/analytics' import db from './renderer/utils/db' -import { T } from '#/i18n/index' +import { T, i18n } from '#/i18n/index' +import { handleURLParams } from '@/utils/beforeOpen' webFrame.setVisualZoomLevelLimits(1, 1) +// do here before vue init +handleURLParams() + Vue.config.productionTip = false Vue.prototype.$builtInPicBed = [ 'smms', @@ -28,6 +32,7 @@ Vue.prototype.$$db = db Vue.prototype.$http = axios Vue.prototype.$bus = bus Vue.prototype.$T = T +Vue.prototype.$i18n = i18n Vue.use(ElementUI) Vue.use(VueLazyLoad) diff --git a/src/main/apis/app/window/windowList.ts b/src/main/apis/app/window/windowList.ts index f0ff282..9920a17 100644 --- a/src/main/apis/app/window/windowList.ts +++ b/src/main/apis/app/window/windowList.ts @@ -10,9 +10,19 @@ import { CREATE_APP_MENU } from '@core/bus/constants' import db from '~/main/apis/core/datastore' import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants' import { app } from 'electron' +import { i18n } from '~/universal/i18n' +import { URLSearchParams } from 'url' const windowList = new Map() +const handleWindowParams = (windowURL: string) => { + const [baseURL, hash = ''] = windowURL.split('#') + const search = new URLSearchParams() + const lang = i18n.getLanguage() + search.append('lang', lang) + return `${baseURL}?${search.toString()}#${hash}` +} + windowList.set(IWindowList.TRAY_WINDOW, { isValid: process.platform !== 'linux', multiple: false, @@ -35,7 +45,7 @@ windowList.set(IWindowList.TRAY_WINDOW, { } }, callback (window) { - window.loadURL(TRAY_WINDOW_URL) + window.loadURL(handleWindowParams(TRAY_WINDOW_URL)) window.on('blur', () => { window.hide() }) @@ -76,7 +86,7 @@ windowList.set(IWindowList.SETTING_WINDOW, { return options }, callback (window, windowManager) { - window.loadURL(SETTING_WINDOW_URL) + window.loadURL(handleWindowParams(SETTING_WINDOW_URL)) window.on('closed', () => { bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, false) if (process.platform === 'linux') { @@ -118,7 +128,7 @@ windowList.set(IWindowList.MINI_WINDOW, { return obj }, callback (window) { - window.loadURL(MINI_WINDOW_URL) + window.loadURL(handleWindowParams(MINI_WINDOW_URL)) } }) @@ -149,7 +159,7 @@ windowList.set(IWindowList.RENAME_WINDOW, { return options }, async callback (window, windowManager) { - window.loadURL(RENAME_WINDOW_URL) + window.loadURL(handleWindowParams(RENAME_WINDOW_URL)) const currentWindow = windowManager.getAvailableWindow() if (currentWindow && currentWindow.isVisible()) { // bounds: { x: 821, y: 75, width: 800, height: 450 } diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 20c3a03..b959e77 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -27,7 +27,8 @@ import { OPEN_URL, RELOAD_APP, SHOW_PLUGIN_PAGE_MENU, - SET_MINI_WINDOW_POS + SET_MINI_WINDOW_POS, + CHANGE_LANGUAGE } from '#/events/constants' import { uploadClipboardFiles, @@ -37,7 +38,7 @@ import picgoCoreIPC from './picgoCoreIPC' import { handleCopyUrl } from '~/main/utils/common' import { buildMainPageMenu, buildMiniPageMenu, buildPluginPageMenu, buildUploadPageMenu } from './remotes/menu' import path from 'path' -import { T } from '~/universal/i18n' +import { i18n, T } from '~/universal/i18n' const STORE_PATH = app.getPath('userData') @@ -223,6 +224,10 @@ export default { const window = BrowserWindow.getFocusedWindow() window?.setBounds(pos) }) + ipcMain.on(CHANGE_LANGUAGE, (evt: IpcMainEvent, lang: string) => { + lang = lang || 'zh-CN' + i18n.setLanguage(lang) + }) }, dispose () {} } diff --git a/src/main/events/picgoCoreIPC.ts b/src/main/events/picgoCoreIPC.ts index 1964db9..b6e4913 100644 --- a/src/main/events/picgoCoreIPC.ts +++ b/src/main/events/picgoCoreIPC.ts @@ -81,9 +81,11 @@ const getPluginList = (): IPicGoPlugin[] => { const pluginPKG = requireFunc(path.join(pluginPath, 'package.json')) const uploaderName = plugin.uploader || '' const transformerName = plugin.transformer || '' - let menu: IGuiMenuItem[] = [] + let menu: Omit[] = [] if (plugin.guiMenu) { - menu = plugin.guiMenu(picgo) + menu = plugin.guiMenu(picgo).map(item => ({ + label: item.label + })) } let gui = false if (pluginPKG.keywords && pluginPKG.keywords.length > 0) { @@ -127,6 +129,8 @@ const getPluginList = (): IPicGoPlugin[] => { const handleGetPluginList = () => { ipcMain.on('getPluginList', (event: IpcMainEvent) => { const list = getPluginList() + // here can just send JS Object not function + // or will cause [Failed to serialize arguments] error event.sender.send('pluginList', list) }) } diff --git a/src/main/lifeCycle/index.ts b/src/main/lifeCycle/index.ts index 1309f27..dcff737 100644 --- a/src/main/lifeCycle/index.ts +++ b/src/main/lifeCycle/index.ts @@ -35,6 +35,7 @@ import { privacyManager } from '~/main/utils/privacyManager' import logger from 'apis/core/picgo/logger' import picgo from 'apis/core/picgo' import fixPath from './fixPath' +import { initI18n } from '~/main/utils/handleI18n' const isDevelopment = process.env.NODE_ENV !== 'production' @@ -61,6 +62,7 @@ class LifeCycle { // fix the $PATH in macOS & linux fixPath() beforeOpen() + initI18n() ipcList.listen() busEventList.listen() updateShortKeyFromVersion212(db, db.get('settings.shortKey')) diff --git a/src/main/utils/handleI18n.ts b/src/main/utils/handleI18n.ts new file mode 100644 index 0000000..bb550bb --- /dev/null +++ b/src/main/utils/handleI18n.ts @@ -0,0 +1,6 @@ +import db from '~/main/apis/core/datastore' +import { i18n } from '#/i18n' +export const initI18n = () => { + const currentLanguage = db.get('settings.language') || 'zh-CN' + i18n.setLanguage(currentLanguage) +} diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 1f2f3e0..6e3deea 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -11,6 +11,24 @@ label-width="10" size="small" > + + + + + + + @@ -350,12 +368,12 @@ import keyDetect from '@/utils/key-binding' import pkg from 'root/package.json' import { IConfig } from 'picgo' -import { PICGO_OPEN_FILE, OPEN_URL } from '#/events/constants' +import { PICGO_OPEN_FILE, OPEN_URL, CHANGE_LANGUAGE } from '#/events/constants' import { ipcRenderer } from 'electron' import { Component, Vue } from 'vue-property-decorator' -import { T } from '~/universal/i18n' +import { T, languageList } from '~/universal/i18n' // import db from '#/datastore' const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest' const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json' @@ -383,9 +401,16 @@ export default class extends Vue { logLevel: ['all'], autoCopyUrl: true, checkBetaUpdate: true, - useBuiltinClipboard: false + useBuiltinClipboard: false, + language: 'zh-CN' } + languageList = languageList.map(item => ({ + label: item, + value: item + })) + + currentLanguage = 'zh-CN' picBed: IPicBedType[] = [] logFileVisible = false keyBindingVisible = false @@ -459,7 +484,8 @@ export default class extends Vue { this.form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy this.form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate this.form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? false : settings.useBuiltinClipboard - + this.form.language = settings.language ?? 'zh-CN' + this.currentLanguage = settings.language ?? 'zh-CN' this.customLink.value = settings.customLink || '$url' this.shortKey.upload = settings.shortKey.upload this.proxy = picBed.proxy || '' @@ -725,6 +751,15 @@ export default class extends Vue { return false } + handleLanguageChange (val: string) { + this.$i18n.setLanguage(val) + this.forceUpdate() + ipcRenderer.send(CHANGE_LANGUAGE, val) + this.saveConfig({ + 'settings.language': val + }) + } + goConfigPage () { ipcRenderer.send(OPEN_URL, 'https://picgo.github.io/PicGo-Doc/zh/guide/config.html#picgo设置') } diff --git a/src/renderer/utils/beforeOpen.ts b/src/renderer/utils/beforeOpen.ts new file mode 100644 index 0000000..6c2e714 --- /dev/null +++ b/src/renderer/utils/beforeOpen.ts @@ -0,0 +1,10 @@ +import { i18n } from '~/universal/i18n' + +export const handleURLParams = () => { + const url = new URL(location.href) + const search = new URLSearchParams(url.search) + if (search.has('lang')) { + const lang = search.get('lang') || 'zh-CN' + i18n.setLanguage(lang) + } +} diff --git a/src/renderer/utils/mainMixin.ts b/src/renderer/utils/mainMixin.ts index 644a804..a4af637 100644 --- a/src/renderer/utils/mainMixin.ts +++ b/src/renderer/utils/mainMixin.ts @@ -1,9 +1,15 @@ import { Component, Vue } from 'vue-property-decorator' import { ipcRenderer, IpcRendererEvent } from 'electron' -import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG } from '#/events/constants' +import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG, FORCE_UPDATE } from '#/events/constants' import { uuid } from 'uuidv4' @Component export default class extends Vue { + created () { + this.$bus.$on(FORCE_UPDATE, () => { + this.$forceUpdate() + }) + } + // support string key + value or object config saveConfig (config: IObj | string, value?: any) { if (typeof config === 'string') { @@ -27,4 +33,8 @@ export default class extends Vue { ipcRenderer.send(PICGO_GET_CONFIG, key, callbackId) }) } + + forceUpdate () { + this.$bus.$emit(FORCE_UPDATE) + } } diff --git a/src/universal/events/constants.ts b/src/universal/events/constants.ts index 9da5161..bf03976 100644 --- a/src/universal/events/constants.ts +++ b/src/universal/events/constants.ts @@ -31,3 +31,5 @@ export const SET_MINI_WINDOW_POS = 'SET_MINI_WINDOW_POS' export const RENAME_FILE_NAME = 'RENAME_FILE_NAME' export const SHOW_MAIN_PAGE_QRCODE = 'SHOW_MAIN_PAGE_QRCODE' export const SHOW_MAIN_PAGE_DONATION = 'SHOW_MAIN_PAGE_DONATION' +export const FORCE_UPDATE = 'FORCE_UPDATE' +export const CHANGE_LANGUAGE = 'CHANGE_LANGUAGE' diff --git a/src/universal/i18n/en.ts b/src/universal/i18n/en.ts new file mode 100644 index 0000000..fbfb851 --- /dev/null +++ b/src/universal/i18n/en.ts @@ -0,0 +1,216 @@ +import { ILocales } from './zh-CN' +/* eslint-disable no-template-curly-in-string */ +export const EN: ILocales = { + ABOUT: 'About', + OPEN_MAIN_WINDOW: 'Open Main Window', + CHOOSE_DEFAULT_PICBED: 'Choose Default Picbed', + OPEN_UPDATE_HELPER: 'Open Update Helper', + PRIVACY_AGREEMENT: 'Privacy Agreement', + RELOAD_APP: 'Reload App', + UPLOAD_FAILED: 'Upload Failed', + UPLOAD_SUCCEED: 'Upload Succeed', + UPLOAD_PROGRESS: 'Upload Progress', + OPERATION_FAILED: 'Operation Failed', + OPERATION_SUCCEED: 'Operation Succeed', + UPLOADING: 'Uploading', + QUICK_UPLOAD: 'Quick Upload', + UPLOAD_BY_CLIPBOARD: 'Upload by Clipboard', + HIDE_WINDOW: 'Hide Window', + SPONSOR_PICGO: 'Sponsor PicGo', + SHOW_PICBED_QRCODE: 'Show Picbed Qrcode', + PICBED_QRCODE: 'Picbed Qrcode', + ENABLE: 'Enable', + DISABLE: 'Disable', + CONFIG_THING: 'Config ${c}', + FIND_NEW_VERSION: 'Find New Version', + SHOW_DEVTOOLS: 'Show Devtools', + NO_MORE_NOTICE: 'No More Notice', + + // ---renderer i18n--- + CHOOSE_YOUR_DEFAULT_PICBED: 'Choose ${d} as your default picbed:', + UPLOAD_AREA: 'Upload Area', + GALLERY: 'Gallery', + PICBEDS_SETTINGS: 'Picbeds Settings', + PICGO_SETTINGS: 'PicGo Settings', + PLUGIN_SETTINGS: 'Plugins Settings', + PICGO_SPONSOR_TEXT: 'PicGo is free software, if you like it, please don\'t forget to buy me a coffee?', + ALIPAY: 'Alipay', + WECHATPAY: 'Wechat Pay', + CHOOSE_PICBED: 'Choose Picbed', + COPY_PICBED_CONFIG: 'Copy Picbed Config', + COPY_PICBED_CONFIG_SUCCEED: 'Copy Picbed Config Succeed', + INPUT: 'Input', + CANCEL: 'Cancel', + CONFIRM: 'Confirm', + CHOOSE_SHOWED_PICBED: 'Choose Showed Picbed', + CHOOSE_PASTE_FORMAT: 'Choose Paste Format', + SEARCH: 'Search', + COPY: 'Copy', + DELETE: 'Delete', + SELECT_ALL: 'Select All', + CHANGE_IMAGE_URL: 'Change Image URL', + CHANGE_IMAGE_URL_SUCCEED: 'Change Image URL Succeed', + COPY_LINK_SUCCEED: 'Copy Link Succeed', + BATCH_COPY_LINK_SUCCEED: 'Batch Copy Link Succeed', + FILE_RENAME: 'File Rename', + + // settings + SETTINGS: 'Settings', + SETTINGS_OPEN_CONFIG_FILE: 'Open Config File', + SETTINGS_CLICK_TO_OPEN: 'Click to Open', + SETTINGS_SET_LOG_FILE: 'Set Log File', + SETTINGS_CLICK_TO_SET: 'Click to Set', + SETTINGS_CLICK_TO_CHECK: 'Click to Check', + SETTINGS_SET_SHORTCUT: 'Set Shortcut', + SETTINGS_CUSTOM_LINK_FORMAT: 'Custom Link Format', + SETTINGS_SET_PROXY_AND_MIRROR: 'Set Proxy and Mirror', + SETTINGS_SET_SERVER: 'Set Server', + SETTINGS_CHECK_UPDATE: 'Check Update', + SETTINGS_OPEN_UPDATE_HELPER: 'Open Update Helper', + SETTINGS_OPEN: 'Open', + SETTINGS_CLOSE: 'Close', + SETTINGS_ACCEPT_BETA_UPDATE: 'Accept Beta Update', + SETTINGS_LAUNCH_ON_BOOT: 'Launch On Boot', + SETTINGS_RENAME_BEFORE_UPLOAD: 'Rename Before Upload', + SETTINGS_TIMESTAMP_RENAME: 'Timestamp Rename', + SETTINGS_OPEN_UPLOAD_TIPS: 'Open Upload Tips', + SETTINGS_MINI_WINDOW_ON_TOP: 'Mini Window On Top', + SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 'Auto Copy URL After Upload', + SETTINGS_TIPS_PLACEHOLDER_URL: 'Use $url to represent url position', + SETTINGS_TIPS_PLACEHOLDER_FILENAME: 'Use $fileName to represent file name position', + SETTINGS_TIPS_SUCH_AS: 'Such as: $url/$fileName', + SETTINGS_UPLOAD_PROXY: 'Upload Proxy', + SETTINGS_PLUGIN_INSTALL_PROXY: 'Proxy for Plugin Install', + SETTINGS_PLUGIN_INSTALL_MIRROR: 'Mirror for Plugin Install', + SETTINGS_CURRENT_VERSION: 'Current Version', + SETTINGS_NEWEST_VERSION: 'Newest Version', + SETTINGS_GETING: 'Getting...', + SETTINGS_TIPS_HAS_NEW_VERSION: 'PicGo has a new version, please click confirm to open download page', + SETTINGS_LOG_FILE: 'Log File', + SETTINGS_LOG_LEVEL: 'Log Level', + SETTINGS_SET_PICGO_SERVER: 'Set PicGo Server', + SETTINGS_TIPS_SERVER_NOTICE: 'If you don\'t know what is the server\'s function, please read the document, or don\'t modify the configuration.', + SETTINGS_ENABLE_SERVER: 'Enable Server', + SETTINGS_SET_SERVER_HOST: 'Set Server Host', + SETTINGS_SET_SERVER_PORT: 'Set Server Port', + SETTINGS_TIP_PLACEHOLDER_HOST: 'Default:127.0.0.1', + SETTINGS_TIP_PLACEHOLDER_PORT: 'Default:36677', + SETTINGS_LOG_LEVEL_ALL: 'All', + SETTINGS_LOG_LEVEL_SUCCESS: 'Success', + SETTINGS_LOG_LEVEL_ERROR: 'Error', + SETTINGS_LOG_LEVEL_INFO: 'Info', + SETTINGS_LOG_LEVEL_WARN: 'Warn', + SETTINGS_LOG_LEVEL_NONE: 'None', + SETTINGS_RESULT: 'Result', + SETTINGS_DEFAULT_PICBED: 'Default Picbed', + SETTINGS_SET_DEFAULT_PICBED: 'Set Default Picbed', + SETTINGS_NOT_CONFIG_OPTIONS: 'Not Config Options', + SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: 'Use Builtin Clipboard to Upload', + SETTINGS_CHOOSE_LANGUAGE: 'Choose Language', + + // shortcut page + SHORTCUT_NAME: 'Shortcut Name', + SHORTCUT_BIND: 'Shortcut Binding', + SHORTCUT_STATUS: 'Status', + SHORTCUT_ENABLED: 'Enabled', + SHORTCUT_DISABLED: 'Disabled', + SHORTCUT_SOURCE: 'Source', + SHORTCUT_HANDLE: 'Handle', + SHORTCUT_ENABLE: 'Enable', + SHORTCUT_DISABLE: 'Disable', + SHORTCUT_EDIT: 'Edit', + SHORTCUT_CHANGE_UPLOAD: 'Change Upload Shortcut', + + // tray page + WAIT_TO_UPLOAD: 'Wait to Upload', + ALREADY_UPLOAD: 'Already Upload', + + // uload page + PICTURE_UPLOAD: 'Picture Upload', + DRAG_FILE_TO_HERE: 'Drag file to here, or', + CLICK_TO_UPLOAD: 'click to upload', + LINK_FORMAT: 'Link Format', + CUSTOM: 'Custom', + CLIPBOARD_PICTURE: 'Clipboard', + TIPS_DRAG_VALID_PICTURE_OR_URL: 'Drag valid picture or url to here', + TIPS_INPUT_URL: 'Input URL', + TIPS_HTTP_PREFIX: 'http:// or https://', + TIPS_INPUT_VALID_URL: 'Input valid URL', + + // plugins + PLUGIN_SEARCH_PLACEHOLDER: 'Search picgo plugins on npm, or click the button to view the awesome plugins list', + PLUGIN_INSTALL: 'Install', + PLUGIN_INSTALLING: 'Installing...', + PLUGIN_INSTALLED: 'Installed', + PLUGIN_DOING_SOMETHING: 'Doing...', + PLUGIN_LIST: 'Plugin List', + PLUGIN_IMPORT_LOCAL: 'Import Local Plugins', + + // tips + TIPS_REMOVE_LINK: 'This operation will remove the picture from the album, continue?', + TIPS_WILL_REMOVE_CHOOSED_IMAGES: 'This operation will remove the picture from the album, continue?', + TIPS_MUST_CONTAINS_URL: 'Must contains $url', + TIPS_NETWORK_ERROR: 'Network Error', + TIPS_NEED_RELOAD: 'Need Reload App', + TIPS_PLEASE_CHOOSE_LOG_LEVEL: 'Please choose log level', + TIPS_SET_SUCCEED: 'Set successfully', + TIPS_PLUGIN_NOT_GUI_IMPLEMENT: 'This plugin is not optimized for the GUI, continue?', + TIPS_CLICK_NOTIFICATION_TO_RELOAD: 'Click notification to reload app', + // ---renderer i18n end--- + + // plugins + PLUGIN_INSTALL_SUCCEED: 'Plugin install succeed', + PLUGIN_INSTALL_FAILED: 'Plugin install failed', + PLUGIN_UNINSTALL_SUCCEED: 'Plugin uninstall succeed', + PLUGIN_UNINSTALL_FAILED: 'Plugin uninstall failed', + PLUGIN_UPDATE_SUCCEED: 'Plugin update succeed', + PLUGIN_UPDATE_FAILED: 'Plugin update failed', + PLUGIN_IMPORT_SUCCEED: 'Plugin import succeed', + PLUGIN_IMPORT_FAILED: 'Plugin import failed', + ENABLE_PLUGIN: 'Enable Plugin', + DISABLE_PLUGIN: 'Disable Plugin', + UNINSTALL_PLUGIN: 'Uninstall Plugin', + UPDATE_PLUGIN: 'Update Plugin', + // tips + TIPS_NOTICE: 'Tips', + TIPS_WARNING: 'Warning', + TIPS_ERROR: 'Error', + TIPS_INSTALL_NODE_AND_RELOAD_PICGO: 'Please install Node.js and restart PicGo to continue', + TIPS_PLUGIN_REMOVE_GALLERY_ITEM: 'Plugin is trying to remove some images from the album, continue?', + TIPS_UPLOAD_NOT_PICTURES: 'The latest clipboard item is not a picture', + TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT: 'PicGo config file broken, has been restored to default', + TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP: 'PicGo config file broken, has been restored to backup', + TIPS_PICGO_BACKUP_FILE_VERSION: 'Backup file version: ${v}', + TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR: 'Custom config file parse error, please check the path content', + TIPS_SHORTCUT_MODIFIED_SUCCEED: 'Shortcut modified successfully', + TIPS_SHORTCUT_MODIFIED_CONFLICT: 'Shortcut conflict, please reset', + TIPS_CUSTOM_LINK_STYLE_MODIFIED_SUCCEED: 'Custom link style modified successfully', + TIPS_FIND_NEW_VERSION: 'Find new version ${v},update many new features, do you want to download the latest version?', + // privcy + PRIVACY: +` +This software respects and protects the personal privacy of all users who use the service. In order to provide you with more accurate and better services, this software will use and collect some of your behavioral information in accordance with the provisions of this Privacy Policy. When you agree to the software service use agreement, you are deemed to have agreed to the entire content of this privacy policy. This privacy policy is an integral part of the software service use agreement, and it will not be used if you do not agree. This Agreement will be updated periodically. + +1. Scope of application + +a) When you use this software, this software will record some information about your operation behavior of this software, including but not limited to the time-consuming, type, quantity and other information of your use of this software to upload files. + +2. Use of Information + +a) After obtaining your usage data, the software will upload it to the data analysis server so as to provide you with better services after analyzing the data. + +3. Information disclosure + +a) This software will not disclose your information to untrusted third parties. + +b) In accordance with the relevant provisions of the law, or the requirements of administrative or judicial institutions, disclose to third parties or administrative or judicial institutions; + +c) If you violate relevant Chinese laws, regulations or relevant rules, you need to disclose it to a third party; + +4. Information Security + +a) This software does not collect your personal information, key information and other private information, and the collected information is only used for improving the software, optimizing the experience, and understanding the daily activities of the software. +`, + // action + QUIT: 'Quit' +} diff --git a/src/universal/i18n/index.ts b/src/universal/i18n/index.ts index f9b49dc..a38ee68 100644 --- a/src/universal/i18n/index.ts +++ b/src/universal/i18n/index.ts @@ -1,11 +1,13 @@ import { ZH_CN } from './zh-CN' +import { EN } from './en' import { ObjectAdapter, I18n } from '@picgo/i18n' -const languageList = { - 'zh-CN': ZH_CN +const languageMap = { + 'zh-CN': ZH_CN, + en: EN } -const objectAdapter = new ObjectAdapter(languageList) +const objectAdapter = new ObjectAdapter(languageMap) const i18n = new I18n({ adapter: objectAdapter, @@ -16,4 +18,6 @@ const T = (key: ILocalesKey, args: IStringKeyMap = {}): string => { return i18n.translate(key, args) || '' } -export { i18n, T } +const languageList = Object.keys(languageMap) + +export { i18n, T, languageList } diff --git a/src/universal/i18n/zh-CN.ts b/src/universal/i18n/zh-CN.ts index 818aee8..12caba9 100644 --- a/src/universal/i18n/zh-CN.ts +++ b/src/universal/i18n/zh-CN.ts @@ -105,6 +105,7 @@ export const ZH_CN = { SETTINGS_SET_DEFAULT_PICBED: '设为默认图床', SETTINGS_NOT_CONFIG_OPTIONS: '暂无配置项', SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: '使用内置剪贴板上传', + SETTINGS_CHOOSE_LANGUAGE: '选择语言', // shortcut page SHORTCUT_NAME: '快捷键名称', @@ -112,7 +113,7 @@ export const ZH_CN = { SHORTCUT_STATUS: '状态', SHORTCUT_ENABLED: '已启用', SHORTCUT_DISABLED: '已禁用', - SHORTCUT_SOURCE: '已禁用', + SHORTCUT_SOURCE: '来源', SHORTCUT_HANDLE: '操作', SHORTCUT_ENABLE: '启用', SHORTCUT_DISABLE: '禁用', @@ -214,3 +215,4 @@ a)本软件不会收集您的个人信息、密钥信息等隐私信息,所收 } export type ILocalesKey = keyof typeof ZH_CN +export type ILocales = typeof ZH_CN diff --git a/src/universal/types/extra-vue.d.ts b/src/universal/types/extra-vue.d.ts index 6d968ac..5dc3592 100644 --- a/src/universal/types/extra-vue.d.ts +++ b/src/universal/types/extra-vue.d.ts @@ -20,9 +20,11 @@ declare module 'vue/types/vue' { $bus: Vue $$db: IGalleryDB $T: typeof import('#/i18n/index').T + $i18n: typeof import('#/i18n/index').i18n saveConfig(data: IObj | string, value?: any): void getConfig(key?: string): Promise setDefaultPicBed(picBed: string): void defaultPicBed: string + forceUpdate(): void } } diff --git a/src/universal/types/view.d.ts b/src/universal/types/view.d.ts index 3cabc14..6b7b80a 100644 --- a/src/universal/types/view.d.ts +++ b/src/universal/types/view.d.ts @@ -10,6 +10,7 @@ interface ISettingForm { autoCopyUrl: boolean checkBetaUpdate: boolean useBuiltinClipboard: boolean + language: string } interface IShortKeyMap {