Fix page translation not working

This commit is contained in:
sienori 2021-01-06 02:00:26 +09:00
parent 2ff56c8b93
commit 6472b21de2
3 changed files with 4 additions and 4 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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);
};