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

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

View File

@@ -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<IGuiMenuItem, 'handle'>[] = []
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)
})
}