feat(client): translate Electron context menu

This commit is contained in:
Elian Doran
2024-11-21 20:58:54 +02:00
parent ea8e98b8ef
commit 2ffd0de736
2 changed files with 17 additions and 7 deletions

View File

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