diff --git a/simple-translate/simple-translate.js b/simple-translate/simple-translate.js index 3e36f33..303d0b2 100644 --- a/simple-translate/simple-translate.js +++ b/simple-translate/simple-translate.js @@ -113,18 +113,20 @@ button.addEventListener( ); async function translate(sourceWord, sourceLang, targetLang) { - const resultData = await T.translate(sourceWord, sourceLang, targetLang); - showResult(resultData.resultText, resultData.candidateText); + const result = await T.translate(sourceWord, sourceLang, targetLang); + showResult(result); panelPosition(clickPosition); } -function showResult(resultText, candidateText) { +function showResult(result) { panel.innerHTML = "
"; const resultArea = panel.getElementsByClassName("result")[0]; const candidateArea = panel.getElementsByClassName("candidate")[0]; - resultArea.innerText = resultText; - if (S.get().ifShowCandidate) candidateArea.innerText = candidateText; + resultArea.innerText = result.resultText; + if (S.get().ifShowCandidate) candidateArea.innerText = result.candidateText; + if (result.statusText == "Service Unavailable") + candidateArea.innerText = browser.i18n.getMessage("unavailableError"); } //パネル表示