Skip to content

Commit

Permalink
refactor(selection-tools): remove redundant getPreferredLanguage ca…
Browse files Browse the repository at this point in the history
…lls (#593)
  • Loading branch information
AiraNadih authored Dec 21, 2023
1 parent 8230f5f commit 2e8911d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/content-script/selection-tools/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const createGenPrompt =
includeLanguagePrefix = false,
}) =>
async (selection) => {
const preferredLanguage = isTranslation ? targetLanguage : await getPreferredLanguage()
let preferredLanguage = targetLanguage

if (!preferredLanguage) {
preferredLanguage = await getPreferredLanguage()
}

let fullMessage = isTranslation
? `Translate the following into ${preferredLanguage} and only show me the translated content`
: message
Expand All @@ -45,7 +50,6 @@ export const config = {
label: 'Translate',
genPrompt: createGenPrompt({
isTranslation: true,
targetLanguage: await getPreferredLanguage(),
}),
},
translateToEn: {
Expand All @@ -69,7 +73,6 @@ export const config = {
label: 'Translate (Bidirectional)',
genPrompt: createGenPrompt({
isTranslation: true,
targetLanguage: await getPreferredLanguage(),
enableBidirectional: true,
}),
},
Expand Down

0 comments on commit 2e8911d

Please sign in to comment.