From 2ffd0de736c59258e7068768f5621f6c656d86e4 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 21 Nov 2024 20:58:54 +0200 Subject: [PATCH] feat(client): translate Electron context menu --- src/public/app/menus/electron_context_menu.js | 15 ++++++++------- src/public/translations/en/translation.json | 9 +++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/public/app/menus/electron_context_menu.js b/src/public/app/menus/electron_context_menu.js index 7c2e96fbd..62dc36191 100644 --- a/src/public/app/menus/electron_context_menu.js +++ b/src/public/app/menus/electron_context_menu.js @@ -2,6 +2,7 @@ import utils from "../services/utils.js"; import options from "../services/options.js"; import zoomService from "../components/zoom.js"; import contextMenu from "./context_menu.js"; +import { t } from "../services/i18n.js"; function setupContextMenu() { const electron = utils.dynamicRequire('electron'); @@ -28,7 +29,7 @@ function setupContextMenu() { } items.push({ - title: `Add "${params.misspelledWord}" to dictionary`, + title: t("electron_context_menu.add-term-to-dictionary", { term: params.misspelledWord }), uiIcon: "bx bx-plus", handler: () => webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord) }); @@ -39,7 +40,7 @@ function setupContextMenu() { if (params.isEditable) { items.push({ enabled: editFlags.canCut && hasText, - title: `Cut`, + title: t("electron_context_menu.cut"), shortcut: `${platformModifier}+X`, uiIcon: "bx bx-cut", handler: () => webContents.cut() @@ -49,7 +50,7 @@ function setupContextMenu() { if (params.isEditable || hasText) { items.push({ enabled: editFlags.canCopy && hasText, - title: `Copy`, + title: t("electron_context_menu.copy"), shortcut: `${platformModifier}+C`, uiIcon: "bx bx-copy", handler: () => webContents.copy() @@ -58,7 +59,7 @@ function setupContextMenu() { if (!["", "javascript:", "about:blank#blocked"].includes(params.linkURL) && params.mediaType === 'none') { items.push({ - title: `Copy link`, + title: t("electron_context_menu.copy-link"), uiIcon: "bx bx-copy", handler: () => { electron.clipboard.write({ @@ -72,7 +73,7 @@ function setupContextMenu() { if (params.isEditable) { items.push({ enabled: editFlags.canPaste, - title: `Paste`, + title: t("electron_context_menu.paste"), shortcut: `${platformModifier}+V`, uiIcon: "bx bx-paste", handler: () => webContents.paste() @@ -82,7 +83,7 @@ function setupContextMenu() { if (params.isEditable) { items.push({ enabled: editFlags.canPaste, - title: `Paste as plain text`, + title: t("electron_context_menu.paste-as-plain-text"), shortcut: `${platformModifier}+Shift+V`, uiIcon: "bx bx-paste", handler: () => webContents.pasteAndMatchStyle() @@ -114,7 +115,7 @@ function setupContextMenu() { items.push({ enabled: editFlags.canPaste, - title: `Search for "${shortenedSelection}" with ${searchEngineName}`, + title: t("electron_context_menu.search_online", { term: shortenedSelection, searchEngine: searchEngineName }), uiIcon: "bx bx-search-alt", handler: () => electron.shell.openExternal(searchUrl) }); diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index 0762f0028..de2377124 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1537,5 +1537,14 @@ "description": "editing tools appear in the \"Formatting\" ribbon tab." } } + }, + "electron_context_menu": { + "add-term-to-dictionary": "Add \"{{term}}\" to dictionary", + "cut": "Cut", + "copy": "Copy", + "copy-link": "Copy link", + "paste": "Paste", + "paste-as-plain-text": "Paste as plain text", + "search_online": "Search for \"{{term}}\" with {{searchEngine}}" } }