Feature: add i18n for en

This commit is contained in:
PiEgg 2022-02-20 21:30:22 +08:00
parent 7f6d58f992
commit 1936ccfedc
15 changed files with 333 additions and 19 deletions

View File

@ -10,10 +10,14 @@ import mainMixin from './renderer/utils/mainMixin'
import bus from '@/utils/bus' import bus from '@/utils/bus'
import { initTalkingData } from './renderer/utils/analytics' import { initTalkingData } from './renderer/utils/analytics'
import db from './renderer/utils/db' 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) webFrame.setVisualZoomLevelLimits(1, 1)
// do here before vue init
handleURLParams()
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$builtInPicBed = [ Vue.prototype.$builtInPicBed = [
'smms', 'smms',
@ -28,6 +32,7 @@ Vue.prototype.$$db = db
Vue.prototype.$http = axios Vue.prototype.$http = axios
Vue.prototype.$bus = bus Vue.prototype.$bus = bus
Vue.prototype.$T = T Vue.prototype.$T = T
Vue.prototype.$i18n = i18n
Vue.use(ElementUI) Vue.use(ElementUI)
Vue.use(VueLazyLoad) Vue.use(VueLazyLoad)

View File

@ -10,9 +10,19 @@ import { CREATE_APP_MENU } from '@core/bus/constants'
import db from '~/main/apis/core/datastore' import db from '~/main/apis/core/datastore'
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants' import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
import { app } from 'electron' import { app } from 'electron'
import { i18n } from '~/universal/i18n'
import { URLSearchParams } from 'url'
const windowList = new Map<IWindowList, IWindowListItem>() const windowList = new Map<IWindowList, IWindowListItem>()
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, { windowList.set(IWindowList.TRAY_WINDOW, {
isValid: process.platform !== 'linux', isValid: process.platform !== 'linux',
multiple: false, multiple: false,
@ -35,7 +45,7 @@ windowList.set(IWindowList.TRAY_WINDOW, {
} }
}, },
callback (window) { callback (window) {
window.loadURL(TRAY_WINDOW_URL) window.loadURL(handleWindowParams(TRAY_WINDOW_URL))
window.on('blur', () => { window.on('blur', () => {
window.hide() window.hide()
}) })
@ -76,7 +86,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
return options return options
}, },
callback (window, windowManager) { callback (window, windowManager) {
window.loadURL(SETTING_WINDOW_URL) window.loadURL(handleWindowParams(SETTING_WINDOW_URL))
window.on('closed', () => { window.on('closed', () => {
bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, false) bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, false)
if (process.platform === 'linux') { if (process.platform === 'linux') {
@ -118,7 +128,7 @@ windowList.set(IWindowList.MINI_WINDOW, {
return obj return obj
}, },
callback (window) { callback (window) {
window.loadURL(MINI_WINDOW_URL) window.loadURL(handleWindowParams(MINI_WINDOW_URL))
} }
}) })
@ -149,7 +159,7 @@ windowList.set(IWindowList.RENAME_WINDOW, {
return options return options
}, },
async callback (window, windowManager) { async callback (window, windowManager) {
window.loadURL(RENAME_WINDOW_URL) window.loadURL(handleWindowParams(RENAME_WINDOW_URL))
const currentWindow = windowManager.getAvailableWindow() const currentWindow = windowManager.getAvailableWindow()
if (currentWindow && currentWindow.isVisible()) { if (currentWindow && currentWindow.isVisible()) {
// bounds: { x: 821, y: 75, width: 800, height: 450 } // bounds: { x: 821, y: 75, width: 800, height: 450 }

View File

@ -27,7 +27,8 @@ import {
OPEN_URL, OPEN_URL,
RELOAD_APP, RELOAD_APP,
SHOW_PLUGIN_PAGE_MENU, SHOW_PLUGIN_PAGE_MENU,
SET_MINI_WINDOW_POS SET_MINI_WINDOW_POS,
CHANGE_LANGUAGE
} from '#/events/constants' } from '#/events/constants'
import { import {
uploadClipboardFiles, uploadClipboardFiles,
@ -37,7 +38,7 @@ import picgoCoreIPC from './picgoCoreIPC'
import { handleCopyUrl } from '~/main/utils/common' import { handleCopyUrl } from '~/main/utils/common'
import { buildMainPageMenu, buildMiniPageMenu, buildPluginPageMenu, buildUploadPageMenu } from './remotes/menu' import { buildMainPageMenu, buildMiniPageMenu, buildPluginPageMenu, buildUploadPageMenu } from './remotes/menu'
import path from 'path' import path from 'path'
import { T } from '~/universal/i18n' import { i18n, T } from '~/universal/i18n'
const STORE_PATH = app.getPath('userData') const STORE_PATH = app.getPath('userData')
@ -223,6 +224,10 @@ export default {
const window = BrowserWindow.getFocusedWindow() const window = BrowserWindow.getFocusedWindow()
window?.setBounds(pos) window?.setBounds(pos)
}) })
ipcMain.on(CHANGE_LANGUAGE, (evt: IpcMainEvent, lang: string) => {
lang = lang || 'zh-CN'
i18n.setLanguage(lang)
})
}, },
dispose () {} dispose () {}
} }

View File

@ -81,9 +81,11 @@ const getPluginList = (): IPicGoPlugin[] => {
const pluginPKG = requireFunc(path.join(pluginPath, 'package.json')) const pluginPKG = requireFunc(path.join(pluginPath, 'package.json'))
const uploaderName = plugin.uploader || '' const uploaderName = plugin.uploader || ''
const transformerName = plugin.transformer || '' const transformerName = plugin.transformer || ''
let menu: IGuiMenuItem[] = [] let menu: Omit<IGuiMenuItem, 'handle'>[] = []
if (plugin.guiMenu) { if (plugin.guiMenu) {
menu = plugin.guiMenu(picgo) menu = plugin.guiMenu(picgo).map(item => ({
label: item.label
}))
} }
let gui = false let gui = false
if (pluginPKG.keywords && pluginPKG.keywords.length > 0) { if (pluginPKG.keywords && pluginPKG.keywords.length > 0) {
@ -127,6 +129,8 @@ const getPluginList = (): IPicGoPlugin[] => {
const handleGetPluginList = () => { const handleGetPluginList = () => {
ipcMain.on('getPluginList', (event: IpcMainEvent) => { ipcMain.on('getPluginList', (event: IpcMainEvent) => {
const list = getPluginList() const list = getPluginList()
// here can just send JS Object not function
// or will cause [Failed to serialize arguments] error
event.sender.send('pluginList', list) event.sender.send('pluginList', list)
}) })
} }

View File

@ -35,6 +35,7 @@ import { privacyManager } from '~/main/utils/privacyManager'
import logger from 'apis/core/picgo/logger' import logger from 'apis/core/picgo/logger'
import picgo from 'apis/core/picgo' import picgo from 'apis/core/picgo'
import fixPath from './fixPath' import fixPath from './fixPath'
import { initI18n } from '~/main/utils/handleI18n'
const isDevelopment = process.env.NODE_ENV !== 'production' const isDevelopment = process.env.NODE_ENV !== 'production'
@ -61,6 +62,7 @@ class LifeCycle {
// fix the $PATH in macOS & linux // fix the $PATH in macOS & linux
fixPath() fixPath()
beforeOpen() beforeOpen()
initI18n()
ipcList.listen() ipcList.listen()
busEventList.listen() busEventList.listen()
updateShortKeyFromVersion212(db, db.get('settings.shortKey')) updateShortKeyFromVersion212(db, db.get('settings.shortKey'))

View File

@ -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)
}

View File

@ -11,6 +11,24 @@
label-width="10" label-width="10"
size="small" size="small"
> >
<el-form-item
:label="$T('SETTINGS_CHOOSE_LANGUAGE')"
>
<!-- <el-button type="primary" round size="mini" @click="openFile('data.json')">{{ $T('SETTINGS_CLICK_TO_OPEN') }}</el-button> -->
<el-select
v-model="currentLanguage"
size="mini"
style="width: 100%"
@change="handleLanguageChange"
:placeholder="$T('SETTINGS_CHOOSE_LANGUAGE')">
<el-option
v-for="item in languageList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item <el-form-item
:label="$T('SETTINGS_OPEN_CONFIG_FILE')" :label="$T('SETTINGS_OPEN_CONFIG_FILE')"
> >
@ -350,12 +368,12 @@
import keyDetect from '@/utils/key-binding' import keyDetect from '@/utils/key-binding'
import pkg from 'root/package.json' import pkg from 'root/package.json'
import { IConfig } from 'picgo' 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 { import {
ipcRenderer ipcRenderer
} from 'electron' } from 'electron'
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import { T } from '~/universal/i18n' import { T, languageList } from '~/universal/i18n'
// import db from '#/datastore' // import db from '#/datastore'
const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest' const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json' const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json'
@ -383,9 +401,16 @@ export default class extends Vue {
logLevel: ['all'], logLevel: ['all'],
autoCopyUrl: true, autoCopyUrl: true,
checkBetaUpdate: true, checkBetaUpdate: true,
useBuiltinClipboard: false useBuiltinClipboard: false,
language: 'zh-CN'
} }
languageList = languageList.map(item => ({
label: item,
value: item
}))
currentLanguage = 'zh-CN'
picBed: IPicBedType[] = [] picBed: IPicBedType[] = []
logFileVisible = false logFileVisible = false
keyBindingVisible = false keyBindingVisible = false
@ -459,7 +484,8 @@ export default class extends Vue {
this.form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy this.form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy
this.form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate this.form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate
this.form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? false : settings.useBuiltinClipboard 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.customLink.value = settings.customLink || '$url'
this.shortKey.upload = settings.shortKey.upload this.shortKey.upload = settings.shortKey.upload
this.proxy = picBed.proxy || '' this.proxy = picBed.proxy || ''
@ -725,6 +751,15 @@ export default class extends Vue {
return false return false
} }
handleLanguageChange (val: string) {
this.$i18n.setLanguage(val)
this.forceUpdate()
ipcRenderer.send(CHANGE_LANGUAGE, val)
this.saveConfig({
'settings.language': val
})
}
goConfigPage () { goConfigPage () {
ipcRenderer.send(OPEN_URL, 'https://picgo.github.io/PicGo-Doc/zh/guide/config.html#picgo设置') ipcRenderer.send(OPEN_URL, 'https://picgo.github.io/PicGo-Doc/zh/guide/config.html#picgo设置')
} }

View File

@ -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)
}
}

View File

@ -1,9 +1,15 @@
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import { ipcRenderer, IpcRendererEvent } from 'electron' 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' import { uuid } from 'uuidv4'
@Component @Component
export default class extends Vue { export default class extends Vue {
created () {
this.$bus.$on(FORCE_UPDATE, () => {
this.$forceUpdate()
})
}
// support string key + value or object config // support string key + value or object config
saveConfig (config: IObj | string, value?: any) { saveConfig (config: IObj | string, value?: any) {
if (typeof config === 'string') { if (typeof config === 'string') {
@ -27,4 +33,8 @@ export default class extends Vue {
ipcRenderer.send(PICGO_GET_CONFIG, key, callbackId) ipcRenderer.send(PICGO_GET_CONFIG, key, callbackId)
}) })
} }
forceUpdate () {
this.$bus.$emit(FORCE_UPDATE)
}
} }

View File

@ -31,3 +31,5 @@ export const SET_MINI_WINDOW_POS = 'SET_MINI_WINDOW_POS'
export const RENAME_FILE_NAME = 'RENAME_FILE_NAME' export const RENAME_FILE_NAME = 'RENAME_FILE_NAME'
export const SHOW_MAIN_PAGE_QRCODE = 'SHOW_MAIN_PAGE_QRCODE' export const SHOW_MAIN_PAGE_QRCODE = 'SHOW_MAIN_PAGE_QRCODE'
export const SHOW_MAIN_PAGE_DONATION = 'SHOW_MAIN_PAGE_DONATION' export const SHOW_MAIN_PAGE_DONATION = 'SHOW_MAIN_PAGE_DONATION'
export const FORCE_UPDATE = 'FORCE_UPDATE'
export const CHANGE_LANGUAGE = 'CHANGE_LANGUAGE'

216
src/universal/i18n/en.ts Normal file
View File

@ -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'
}

View File

@ -1,11 +1,13 @@
import { ZH_CN } from './zh-CN' import { ZH_CN } from './zh-CN'
import { EN } from './en'
import { ObjectAdapter, I18n } from '@picgo/i18n' import { ObjectAdapter, I18n } from '@picgo/i18n'
const languageList = { const languageMap = {
'zh-CN': ZH_CN 'zh-CN': ZH_CN,
en: EN
} }
const objectAdapter = new ObjectAdapter(languageList) const objectAdapter = new ObjectAdapter(languageMap)
const i18n = new I18n({ const i18n = new I18n({
adapter: objectAdapter, adapter: objectAdapter,
@ -16,4 +18,6 @@ const T = (key: ILocalesKey, args: IStringKeyMap = {}): string => {
return i18n.translate(key, args) || '' return i18n.translate(key, args) || ''
} }
export { i18n, T } const languageList = Object.keys(languageMap)
export { i18n, T, languageList }

View File

@ -105,6 +105,7 @@ export const ZH_CN = {
SETTINGS_SET_DEFAULT_PICBED: '设为默认图床', SETTINGS_SET_DEFAULT_PICBED: '设为默认图床',
SETTINGS_NOT_CONFIG_OPTIONS: '暂无配置项', SETTINGS_NOT_CONFIG_OPTIONS: '暂无配置项',
SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: '使用内置剪贴板上传', SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: '使用内置剪贴板上传',
SETTINGS_CHOOSE_LANGUAGE: '选择语言',
// shortcut page // shortcut page
SHORTCUT_NAME: '快捷键名称', SHORTCUT_NAME: '快捷键名称',
@ -112,7 +113,7 @@ export const ZH_CN = {
SHORTCUT_STATUS: '状态', SHORTCUT_STATUS: '状态',
SHORTCUT_ENABLED: '已启用', SHORTCUT_ENABLED: '已启用',
SHORTCUT_DISABLED: '已禁用', SHORTCUT_DISABLED: '已禁用',
SHORTCUT_SOURCE: '已禁用', SHORTCUT_SOURCE: '来源',
SHORTCUT_HANDLE: '操作', SHORTCUT_HANDLE: '操作',
SHORTCUT_ENABLE: '启用', SHORTCUT_ENABLE: '启用',
SHORTCUT_DISABLE: '禁用', SHORTCUT_DISABLE: '禁用',
@ -214,3 +215,4 @@ a)本软件不会收集您的个人信息、密钥信息等隐私信息,所收
} }
export type ILocalesKey = keyof typeof ZH_CN export type ILocalesKey = keyof typeof ZH_CN
export type ILocales = typeof ZH_CN

View File

@ -20,9 +20,11 @@ declare module 'vue/types/vue' {
$bus: Vue $bus: Vue
$$db: IGalleryDB $$db: IGalleryDB
$T: typeof import('#/i18n/index').T $T: typeof import('#/i18n/index').T
$i18n: typeof import('#/i18n/index').i18n
saveConfig(data: IObj | string, value?: any): void saveConfig(data: IObj | string, value?: any): void
getConfig<T>(key?: string): Promise<T | undefined> getConfig<T>(key?: string): Promise<T | undefined>
setDefaultPicBed(picBed: string): void setDefaultPicBed(picBed: string): void
defaultPicBed: string defaultPicBed: string
forceUpdate(): void
} }
} }

View File

@ -10,6 +10,7 @@ interface ISettingForm {
autoCopyUrl: boolean autoCopyUrl: boolean
checkBetaUpdate: boolean checkBetaUpdate: boolean
useBuiltinClipboard: boolean useBuiltinClipboard: boolean
language: string
} }
interface IShortKeyMap { interface IShortKeyMap {