--- a/EditTextView.st Wed Jan 29 17:25:33 2020 +0100
+++ b/EditTextView.st Wed Jan 29 17:40:14 2020 +0100
@@ -7497,7 +7497,7 @@
googleTranslate:original from:sourceLang to:targetLang
"translate the selected text and return it"
- |response url o translated|
+ |response url o translated data|
self withWaitCursorDo:[
url := 'http://translate.googleapis.com/translate_a/single?client=gtx&sl=%1&tl=%2&dt=t&ie=UTF-8&oe=UTF-8&q=%3'
@@ -7511,7 +7511,11 @@
"/ response := HTTPInterface post:url with:req.
].
response isErrorResponse ifTrue:[^ nil].
- o := JSONReader decode:response data.
+ data := response data.
+ response encoding = 'utf-8' ifTrue:[
+ data := data utf8Decoded
+ ].
+ o := JSONReader decode:data.
translated := o first first first.
translated isEmpty ifTrue:[^ nil].
^ translated