mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	feat(client): translate Electron context menu
This commit is contained in:
		
							parent
							
								
									ea8e98b8ef
								
							
						
					
					
						commit
						2ffd0de736
					
				| @ -2,6 +2,7 @@ import utils from "../services/utils.js"; | |||||||
| import options from "../services/options.js"; | import options from "../services/options.js"; | ||||||
| import zoomService from "../components/zoom.js"; | import zoomService from "../components/zoom.js"; | ||||||
| import contextMenu from "./context_menu.js"; | import contextMenu from "./context_menu.js"; | ||||||
|  | import { t } from "../services/i18n.js"; | ||||||
| 
 | 
 | ||||||
| function setupContextMenu() { | function setupContextMenu() { | ||||||
|     const electron = utils.dynamicRequire('electron'); |     const electron = utils.dynamicRequire('electron'); | ||||||
| @ -28,7 +29,7 @@ function setupContextMenu() { | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             items.push({ |             items.push({ | ||||||
|                 title: `Add "${params.misspelledWord}" to dictionary`, |                 title: t("electron_context_menu.add-term-to-dictionary", { term: params.misspelledWord }), | ||||||
|                 uiIcon: "bx bx-plus", |                 uiIcon: "bx bx-plus", | ||||||
|                 handler: () => webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord) |                 handler: () => webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord) | ||||||
|             }); |             }); | ||||||
| @ -39,7 +40,7 @@ function setupContextMenu() { | |||||||
|         if (params.isEditable) { |         if (params.isEditable) { | ||||||
|             items.push({ |             items.push({ | ||||||
|                 enabled: editFlags.canCut && hasText, |                 enabled: editFlags.canCut && hasText, | ||||||
|                 title: `Cut`, |                 title: t("electron_context_menu.cut"), | ||||||
|                 shortcut: `${platformModifier}+X`, |                 shortcut: `${platformModifier}+X`, | ||||||
|                 uiIcon: "bx bx-cut", |                 uiIcon: "bx bx-cut", | ||||||
|                 handler: () => webContents.cut() |                 handler: () => webContents.cut() | ||||||
| @ -49,7 +50,7 @@ function setupContextMenu() { | |||||||
|         if (params.isEditable || hasText) { |         if (params.isEditable || hasText) { | ||||||
|             items.push({ |             items.push({ | ||||||
|                 enabled: editFlags.canCopy && hasText, |                 enabled: editFlags.canCopy && hasText, | ||||||
|                 title: `Copy`, |                 title: t("electron_context_menu.copy"), | ||||||
|                 shortcut: `${platformModifier}+C`, |                 shortcut: `${platformModifier}+C`, | ||||||
|                 uiIcon: "bx bx-copy", |                 uiIcon: "bx bx-copy", | ||||||
|                 handler: () => webContents.copy() |                 handler: () => webContents.copy() | ||||||
| @ -58,7 +59,7 @@ function setupContextMenu() { | |||||||
| 
 | 
 | ||||||
|         if (!["", "javascript:", "about:blank#blocked"].includes(params.linkURL) && params.mediaType === 'none') { |         if (!["", "javascript:", "about:blank#blocked"].includes(params.linkURL) && params.mediaType === 'none') { | ||||||
|             items.push({ |             items.push({ | ||||||
|                 title: `Copy link`, |                 title: t("electron_context_menu.copy-link"), | ||||||
|                 uiIcon: "bx bx-copy", |                 uiIcon: "bx bx-copy", | ||||||
|                 handler: () => { |                 handler: () => { | ||||||
|                     electron.clipboard.write({ |                     electron.clipboard.write({ | ||||||
| @ -72,7 +73,7 @@ function setupContextMenu() { | |||||||
|         if (params.isEditable) { |         if (params.isEditable) { | ||||||
|             items.push({ |             items.push({ | ||||||
|                 enabled: editFlags.canPaste, |                 enabled: editFlags.canPaste, | ||||||
|                 title: `Paste`, |                 title: t("electron_context_menu.paste"), | ||||||
|                 shortcut: `${platformModifier}+V`, |                 shortcut: `${platformModifier}+V`, | ||||||
|                 uiIcon: "bx bx-paste", |                 uiIcon: "bx bx-paste", | ||||||
|                 handler: () => webContents.paste() |                 handler: () => webContents.paste() | ||||||
| @ -82,7 +83,7 @@ function setupContextMenu() { | |||||||
|         if (params.isEditable) { |         if (params.isEditable) { | ||||||
|             items.push({ |             items.push({ | ||||||
|                 enabled: editFlags.canPaste, |                 enabled: editFlags.canPaste, | ||||||
|                 title: `Paste as plain text`, |                 title: t("electron_context_menu.paste-as-plain-text"), | ||||||
|                 shortcut: `${platformModifier}+Shift+V`, |                 shortcut: `${platformModifier}+Shift+V`, | ||||||
|                 uiIcon: "bx bx-paste", |                 uiIcon: "bx bx-paste", | ||||||
|                 handler: () => webContents.pasteAndMatchStyle() |                 handler: () => webContents.pasteAndMatchStyle() | ||||||
| @ -114,7 +115,7 @@ function setupContextMenu() { | |||||||
| 
 | 
 | ||||||
|             items.push({ |             items.push({ | ||||||
|                 enabled: editFlags.canPaste, |                 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", |                 uiIcon: "bx bx-search-alt", | ||||||
|                 handler: () => electron.shell.openExternal(searchUrl) |                 handler: () => electron.shell.openExternal(searchUrl) | ||||||
|             }); |             }); | ||||||
|  | |||||||
| @ -1537,5 +1537,14 @@ | |||||||
|         "description": "editing tools appear in the \"Formatting\" ribbon tab." |         "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}}" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran