Skip to content

Commit

Permalink
refactor(selection-tools): remove redundant getPreferredLanguage calls
Browse files Browse the repository at this point in the history
  • Loading branch information
AiraNadih committed Dec 16, 2023
1 parent 79f3b86 commit b563a0d
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 b563a0d

Please sign in to comment.