Skip to content

Commit bc273ea

Browse files
committed
feat: new selection tool translate to english (#240)
1 parent f734b5e commit bc273ea

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

src/_locales/en/main.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"Summarize Page": "Summarize Page",
5555
"Translate": "Translate",
5656
"Translate (Bidirectional)": "Translate (Bidirectional)",
57+
"Translate (To English)": "Translate (To English)",
5758
"Summary": "Summary",
5859
"Polish": "Polish",
5960
"Sentiment Analysis": "Sentiment Analysis",

src/_locales/zh-hans/main.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"Summarize Page": "总结本页",
5555
"Translate": "翻译",
5656
"Translate (Bidirectional)": "双向翻译",
57+
"Translate (To English)": "翻译为英语",
5758
"Summary": "总结",
5859
"Polish": "润色",
5960
"Sentiment Analysis": "情感分析",

src/_locales/zh-hant/main.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"Summarize Page": "摘要本頁",
5555
"Translate": "翻譯",
5656
"Translate (Bidirectional)": "雙向翻譯",
57+
"Translate (To English)": "翻譯為英語",
5758
"Summary": "摘要",
5859
"Polish": "潤色",
5960
"Sentiment Analysis": "情感分析",

src/config/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export const defaultConfig = {
134134
userLanguage: getNavigatorLanguage(),
135135
selectionTools: [
136136
'translate',
137+
'translateToEn',
137138
'translateBidi',
138139
'summary',
139140
'polish',
@@ -144,6 +145,7 @@ export const defaultConfig = {
144145
],
145146
selectionToolsDesc: [
146147
'Translate',
148+
'Translate (To English)',
147149
'Translate (Bidirectional)',
148150
'Summary',
149151
'Polish',

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ export const config = {
1616
label: 'Translate',
1717
genPrompt: async (selection) => {
1818
const preferredLanguage = await getPreferredLanguage()
19-
return `Translate the following into ${preferredLanguage} and only show me the translated content:\n"${selection}"`
19+
return `Translate the following into ${preferredLanguage} and only show me the translated content:\n${selection}`
20+
},
21+
},
22+
translateToEn: {
23+
icon: <Globe />,
24+
label: 'Translate (To English)',
25+
genPrompt: async (selection) => {
26+
return `Translate the following into English and only show me the translated content:\n${selection}`
2027
},
2128
},
2229
translateBidi: {
@@ -27,7 +34,7 @@ export const config = {
2734
return (
2835
`Translate the following into ${preferredLanguage} and only show me the translated content.` +
2936
`If it is already in ${preferredLanguage},` +
30-
`translate it into English and only show me the translated content:\n"${selection}"`
37+
`translate it into English and only show me the translated content:\n${selection}`
3138
)
3239
},
3340
},

0 commit comments

Comments
 (0)