Skip to content

Commit ce05b30

Browse files
committed
feat: direct translation and bidi translation
1 parent 94aa37c commit ce05b30

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const defaultConfig = {
7171

7272
// others
7373

74-
activeSelectionTools: Object.keys(toolsConfig),
74+
activeSelectionTools: Object.keys(toolsConfig).filter((i) => i !== 'translateBidi'),
7575
activeSiteAdapters: [
7676
'bilibili',
7777
'github',

src/content-script/selection-tools/index.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ import {
66
QuestionCircle,
77
Translate,
88
Braces,
9+
Globe,
910
} from 'react-bootstrap-icons'
1011
import { getPreferredLanguage } from '../../config.mjs'
1112

1213
export const config = {
1314
translate: {
1415
icon: <Translate />,
1516
label: 'Translate',
17+
genPrompt: async (selection) => {
18+
const preferredLanguage = await getPreferredLanguage()
19+
return `Translate the following into ${preferredLanguage} and only show me the translated content:\n"${selection}"`
20+
},
21+
},
22+
translateBidi: {
23+
icon: <Globe />,
24+
label: 'Translate (Bidirectional)',
1625
genPrompt: async (selection) => {
1726
const preferredLanguage = await getPreferredLanguage()
1827
return (

0 commit comments

Comments
 (0)