Skip to content

Commit 1a1d8ab

Browse files
committed
fix: electron context menu i18n
Signed-off-by: Innei <i@innei.in>
1 parent f278377 commit 1a1d8ab

File tree

7 files changed

+62
-6
lines changed

7 files changed

+62
-6
lines changed

apps/main/src/init.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@ export const initializeAppStage1 = () => {
5555
registerMenuAndContextMenu()
5656
}
5757

58+
let contextMenuDisposer: () => void
5859
export const registerMenuAndContextMenu = () => {
5960
registerAppMenu()
60-
contextMenu({
61+
if (contextMenuDisposer) {
62+
contextMenuDisposer()
63+
}
64+
65+
contextMenuDisposer = contextMenu({
6166
showSaveImageAs: true,
6267
showCopyLink: true,
6368
showCopyImageAddress: true,
@@ -75,6 +80,17 @@ export const registerMenuAndContextMenu = () => {
7580
copyVideoAddress: t("contextMenu.copyVideoAddress"),
7681
saveVideoAs: t("contextMenu.saveVideoAs"),
7782
inspect: t("contextMenu.inspect"),
83+
copy: t("contextMenu.copy"),
84+
cut: t("contextMenu.cut"),
85+
paste: t("contextMenu.paste"),
86+
saveImage: t("contextMenu.saveImage"),
87+
saveVideo: t("contextMenu.saveVideo"),
88+
selectAll: t("contextMenu.selectAll"),
89+
services: t("contextMenu.services"),
90+
searchWithGoogle: t("contextMenu.searchWithGoogle"),
91+
learnSpelling: t("contextMenu.learnSpelling"),
92+
lookUpSelection: t("contextMenu.lookUpSelection"),
93+
saveLinkAs: t("contextMenu.saveLinkAs"),
7894
},
7995

8096
prepend: (_defaultActions, params) => {

apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING, views } from "~/constants"
1313
import { shortcuts } from "~/constants/shortcuts"
1414
import { useRouteParams } from "~/hooks/biz/useRouteParams"
1515
import { useIsOnline } from "~/hooks/common"
16+
import { stopPropagation } from "~/lib/dom"
1617
import { FeedViewType } from "~/lib/enum"
1718
import { cn, getOS, isBizId } from "~/lib/utils"
1819
import { useAIDailyReportModal } from "~/modules/ai/ai-daily/hooks"
@@ -85,7 +86,7 @@ export const EntryListHeader: FC<{
8586

8687
"translate-x-[6px]",
8788
)}
88-
onClick={(e) => e.stopPropagation()}
89+
onClick={stopPropagation}
8990
>
9091
{views[view].wideMode && entryId && entryId !== ROUTE_ENTRY_PENDING && (
9192
<>

locales/native/en.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
{
2+
"contextMenu.copy": "Copy",
23
"contextMenu.copyImage": "Copy Image",
34
"contextMenu.copyImageAddress": "Copy Image Address",
45
"contextMenu.copyLink": "Copy Link",
56
"contextMenu.copyVideoAddress": "Copy Video Address",
7+
"contextMenu.cut": "Cut",
68
"contextMenu.inspect": "Inspect Element",
9+
"contextMenu.learnSpelling": "Learn Spelling",
10+
"contextMenu.lookUpSelection": "Look Up Selection",
711
"contextMenu.openImageInBrowser": "Open Image in Browser",
812
"contextMenu.openLinkInBrowser": "Open Link in Browser",
13+
"contextMenu.paste": "Paste",
14+
"contextMenu.saveImage": "Save Image",
915
"contextMenu.saveImageAs": "Save Image As...",
16+
"contextMenu.saveLinkAs": "Save Link As...",
17+
"contextMenu.saveVideo": "Save Video",
1018
"contextMenu.saveVideoAs": "Save Video As...",
19+
"contextMenu.searchWithGoogle": "Search with Google",
20+
"contextMenu.selectAll": "Select All",
21+
"contextMenu.services": "Services",
1122
"menu.about": "About {{name}}",
1223
"menu.actualSize": "Actual Size",
1324
"menu.bringAllToFront": "Bring All to Front",

locales/native/zh-CN.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{
2+
"contextMenu.copy": "复制",
23
"contextMenu.copyImage": "复制图片",
34
"contextMenu.copyImageAddress": "复制图片地址",
45
"contextMenu.copyLink": "复制链接",
56
"contextMenu.copyVideoAddress": "复制视频地址",
7+
"contextMenu.cut": "剪切",
68
"contextMenu.inspect": "检查元素",
9+
"contextMenu.learnSpelling": "学习拼写",
10+
"contextMenu.lookUpSelection": "在词典中查找",
711
"contextMenu.openImageInBrowser": "在浏览器中打开图片",
812
"contextMenu.openLinkInBrowser": "在浏览器中打开链接",
13+
"contextMenu.paste": "粘贴",
14+
"contextMenu.pasteAndMatchStyle": "粘贴并匹配样式",
15+
"contextMenu.saveImage": "保存图片",
916
"contextMenu.saveImageAs": "图片另存为...",
17+
"contextMenu.saveLinkAs": "链接另存为...",
18+
"contextMenu.saveVideo": "保存视频",
1019
"contextMenu.saveVideoAs": "视频另存为...",
20+
"contextMenu.searchWithGoogle": "在谷歌中搜索",
21+
"contextMenu.selectAll": "全选",
22+
"contextMenu.services": "服务",
1123
"menu.about": "关于 {{name}}",
1224
"menu.actualSize": "实际大小",
1325
"menu.bringAllToFront": "全部置于顶层",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
"immer@10.1.1": "patches/immer@10.1.1.patch",
110110
"@mozilla/readability@0.5.0": "patches/@mozilla__readability@0.5.0.patch",
111111
"re-resizable": "patches/re-resizable@6.9.17.patch",
112-
"hono": "patches/hono.patch"
112+
"hono": "patches/hono.patch",
113+
"electron-context-menu": "patches/electron-context-menu.patch"
113114
},
114115
"overrides": {
115116
"is-core-module": "npm:@nolyfill/is-core-module@^1",

patches/electron-context-menu.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/index.js b/index.js
2+
index b10daea2fbcee2eaeed9c61103eb89d93d4ee50d..5392745cdcdead1fbb39c17c42f3ed15f4141e35 100644
3+
--- a/index.js
4+
+++ b/index.js
5+
@@ -378,6 +378,7 @@ export default function contextMenu(options = {}) {
6+
};
7+
8+
webContents(win).once('destroyed', disposable);
9+
+ disposables.push(disposable);
10+
};
11+
12+
const dispose = () => {

pnpm-lock.yaml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)