diff --git a/src/config.mjs b/src/config.mjs index f64a8db..f3a3b67 100644 --- a/src/config.mjs +++ b/src/config.mjs @@ -71,7 +71,7 @@ export const defaultConfig = { // others - activeSelectionTools: Object.keys(toolsConfig), + activeSelectionTools: Object.keys(toolsConfig).filter((i) => i !== 'translateBidi'), activeSiteAdapters: [ 'bilibili', 'github', diff --git a/src/content-script/selection-tools/index.mjs b/src/content-script/selection-tools/index.mjs index 835cd06..3b7fa07 100644 --- a/src/content-script/selection-tools/index.mjs +++ b/src/content-script/selection-tools/index.mjs @@ -6,6 +6,7 @@ import { QuestionCircle, Translate, Braces, + Globe, } from 'react-bootstrap-icons' import { getPreferredLanguage } from '../../config.mjs' @@ -13,6 +14,14 @@ export const config = { translate: { icon: , label: 'Translate', + genPrompt: async (selection) => { + const preferredLanguage = await getPreferredLanguage() + return `Translate the following into ${preferredLanguage} and only show me the translated content:\n"${selection}"` + }, + }, + translateBidi: { + icon: , + label: 'Translate (Bidirectional)', genPrompt: async (selection) => { const preferredLanguage = await getPreferredLanguage() return (