🚧 WIP: main process i18n

This commit is contained in:
PiEgg
2022-01-11 21:50:29 +08:00
parent c2991dde2f
commit c19f741243
13 changed files with 121 additions and 60 deletions

View File

@@ -215,7 +215,7 @@ export function createTray () {
for (let i = 0; i < imgs.length; i++) {
pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))
const notification = new Notification({
title: T('UPLOAD_SUCCESSFULLY'),
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!,
icon: files[i]
})

View File

@@ -9,6 +9,7 @@ import pasteTemplate from '~/main/utils/pasteTemplate'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import { handleCopyUrl } from '~/main/utils/common'
import { handleUrlEncode } from '#/utils/common'
import { T } from '#/i18n/index'
export const uploadClipboardFiles = async (): Promise<string> => {
const win = windowManager.getAvailableWindow()
const img = await uploader.setWebContents(win!.webContents).upload()
@@ -18,7 +19,7 @@ export const uploadClipboardFiles = async (): Promise<string> => {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))
const notification = new Notification({
title: '上传成功',
title: T('UPLOAD_SUCCEED'),
body: img[0].imgUrl!,
icon: img[0].imgUrl
})
@@ -33,8 +34,8 @@ export const uploadClipboardFiles = async (): Promise<string> => {
return handleUrlEncode(img[0].imgUrl as string)
} else {
const notification = new Notification({
title: '上传不成功',
body: '你剪贴板最新的一条记录不是图片哦'
title: T('UPLOAD_FAILED'),
body: T('TIPS_UPLOAD_NOT_PICTURES')
})
notification.show()
return ''
@@ -54,7 +55,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
for (let i = 0; i < imgs.length; i++) {
pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))
const notification = new Notification({
title: '上传成功',
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!,
icon: files[i].path
})

View File

@@ -14,6 +14,7 @@ import { IPicGo } from 'picgo'
import { showNotification, calcDurationRange } from '~/main/utils/common'
import { RENAME_FILE_NAME, TALKING_DATA_EVENT } from '~/universal/events/constants'
import logger from '@core/picgo/logger'
import { T } from '~/universal/i18n'
const waitForShow = (webcontent: WebContents) => {
return new Promise<void>((resolve) => {
@@ -71,8 +72,8 @@ class Uploader {
picgo.on('beforeTransform', () => {
if (db.get('settings.uploadNotification')) {
const notification = new Notification({
title: '上传进度',
body: '正在上传'
title: T('UPLOAD_PROGRESS'),
body: T('UPLOADING')
})
notification.show()
}
@@ -129,7 +130,7 @@ class Uploader {
logger.error(e)
setTimeout(() => {
showNotification({
title: '上传失败',
title: T('UPLOAD_FAILED'),
body: util.format(e.stack),
clickToCopy: true
})