diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 54be1f5..5792182 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -15,6 +15,9 @@ "showLink": { "message": "Translate this page" }, + "openInGoogleLabel": { + "message": "Open in Google Translate" + }, "targetLangLabel": { "message": "Target language" }, diff --git a/src/popup/components/PopupPage.js b/src/popup/components/PopupPage.js index 3a59155..3ee48ae 100644 --- a/src/popup/components/PopupPage.js +++ b/src/popup/components/PopupPage.js @@ -111,6 +111,8 @@ export default class PopupPage extends Component {
{ @@ -13,11 +15,23 @@ export default props => { const isError = statusText !== "OK"; const shouldShowCandidate = getSettings("ifShowCandidate"); + const handleLinkClick = () => { + const { inputText, targetLang } = props; + const encodedText = encodeURIComponent(inputText); + const translateUrl = `https://translate.google.com/?sl=auto&tl=${targetLang}&text=${encodedText}`; + openUrl(translateUrl); + }; + return (

{splitLine(resultText)}

{shouldShowCandidate &&

{splitLine(candidateText)}

} {isError &&

{getErrorMessage(statusText)}

} + {isError && ( +

+ {browser.i18n.getMessage("openInGoogleLabel")} +

+ )}
); }; diff --git a/src/popup/styles/ResultArea.scss b/src/popup/styles/ResultArea.scss index ea0d15d..af10a20 100644 --- a/src/popup/styles/ResultArea.scss +++ b/src/popup/styles/ResultArea.scss @@ -23,4 +23,16 @@ } } } + + .translateLink { + a { + font-style: normal; + text-decoration: none; + color: var(--highlight); + cursor: pointer; + &:hover { + text-decoration: underline; + } + } + } }