From 6472b21de2e2a7a37e491a35a83a5c00e0ee31d6 Mon Sep 17 00:00:00 2001 From: sienori Date: Wed, 6 Jan 2021 02:00:26 +0900 Subject: [PATCH] Fix page translation not working --- src/background/keyboardShortcuts.js | 2 +- src/background/menus.js | 4 ++-- src/popup/components/Footer.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/background/keyboardShortcuts.js b/src/background/keyboardShortcuts.js index 0236fc7..6a04f6e 100644 --- a/src/background/keyboardShortcuts.js +++ b/src/background/keyboardShortcuts.js @@ -54,7 +54,7 @@ const translatePage = async () => { const targetLang = getSettings("targetLang"); const encodedPageUrl = encodeURIComponent(tabUrl); - const translationUrl = `https://translate.google.com/translate?hl=${targetLang}&sl=auto&u=${encodedPageUrl}`; + const translationUrl = `https://translate.google.com/translate?hl=${targetLang}&tl=${targetLang}&sl=auto&u=${encodedPageUrl}`; browser.tabs.create({ url: translationUrl, diff --git a/src/background/menus.js b/src/background/menus.js index f2c4e9a..6b3b518 100644 --- a/src/background/menus.js +++ b/src/background/menus.js @@ -81,7 +81,7 @@ function translateText(tab) { function translatePage(info, tab) { const targetLang = getSettings("targetLang"); const encodedPageUrl = encodeURIComponent(info.pageUrl); - const translationUrl = `https://translate.google.com/translate?hl=${targetLang}&sl=auto&u=${encodedPageUrl}`; + const translationUrl = `https://translate.google.com/translate?hl=${targetLang}&tl=${targetLang}&sl=auto&u=${encodedPageUrl}`; browser.tabs.create({ url: translationUrl, @@ -93,7 +93,7 @@ function translatePage(info, tab) { function translateLink(info, tab) { const targetLang = getSettings("targetLang"); const encodedLinkUrl = encodeURIComponent(info.linkUrl); - const translationUrl = `https://translate.google.com/translate?hl=${targetLang}&sl=auto&u=${encodedLinkUrl}`; + const translationUrl = `https://translate.google.com/translate?hl=${targetLang}&tl=${targetLang}&sl=auto&u=${encodedLinkUrl}`; browser.tabs.create({ url: translationUrl, diff --git a/src/popup/components/Footer.js b/src/popup/components/Footer.js index 02805cf..ba627e4 100644 --- a/src/popup/components/Footer.js +++ b/src/popup/components/Footer.js @@ -13,7 +13,7 @@ export default class Footer extends Component { handleLinkClick = async () => { const { tabUrl, targetLang } = this.props; const encodedUrl = encodeURIComponent(tabUrl); - const translateUrl = `https://translate.google.com/translate?hl=${targetLang}&sl=auto&u=${encodedUrl}`; + const translateUrl = `https://translate.google.com/translate?hl=${targetLang}&tl=${targetLang}&sl=auto&u=${encodedUrl}`; openUrl(translateUrl); };