Skip to content

Commit

Permalink
feat: new selection tool translate to english (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Apr 21, 2023
1 parent f734b5e commit bc273ea
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/_locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"Summarize Page": "Summarize Page",
"Translate": "Translate",
"Translate (Bidirectional)": "Translate (Bidirectional)",
"Translate (To English)": "Translate (To English)",
"Summary": "Summary",
"Polish": "Polish",
"Sentiment Analysis": "Sentiment Analysis",
Expand Down
1 change: 1 addition & 0 deletions src/_locales/zh-hans/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"Summarize Page": "总结本页",
"Translate": "翻译",
"Translate (Bidirectional)": "双向翻译",
"Translate (To English)": "翻译为英语",
"Summary": "总结",
"Polish": "润色",
"Sentiment Analysis": "情感分析",
Expand Down
1 change: 1 addition & 0 deletions src/_locales/zh-hant/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"Summarize Page": "摘要本頁",
"Translate": "翻譯",
"Translate (Bidirectional)": "雙向翻譯",
"Translate (To English)": "翻譯為英語",
"Summary": "摘要",
"Polish": "潤色",
"Sentiment Analysis": "情感分析",
Expand Down
2 changes: 2 additions & 0 deletions src/config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const defaultConfig = {
userLanguage: getNavigatorLanguage(),
selectionTools: [
'translate',
'translateToEn',
'translateBidi',
'summary',
'polish',
Expand All @@ -144,6 +145,7 @@ export const defaultConfig = {
],
selectionToolsDesc: [
'Translate',
'Translate (To English)',
'Translate (Bidirectional)',
'Summary',
'Polish',
Expand Down
11 changes: 9 additions & 2 deletions src/content-script/selection-tools/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ export const config = {
label: 'Translate',
genPrompt: async (selection) => {
const preferredLanguage = await getPreferredLanguage()
return `Translate the following into ${preferredLanguage} and only show me the translated content:\n"${selection}"`
return `Translate the following into ${preferredLanguage} and only show me the translated content:\n${selection}`
},
},
translateToEn: {
icon: <Globe />,
label: 'Translate (To English)',
genPrompt: async (selection) => {
return `Translate the following into English and only show me the translated content:\n${selection}`
},
},
translateBidi: {
Expand All @@ -27,7 +34,7 @@ export const config = {
return (
`Translate the following into ${preferredLanguage} and only show me the translated content.` +
`If it is already in ${preferredLanguage},` +
`translate it into English and only show me the translated content:\n"${selection}"`
`translate it into English and only show me the translated content:\n${selection}`
)
},
},
Expand Down

0 comments on commit bc273ea

Please sign in to comment.