#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Wed, 29 Jan 2020 17:40:14 +0100
changeset 6805 5727b638c90d
parent 6804 b54520ce43f3
child 6806 dc046647db8c
#BUGFIX by cg class: EditTextView changed: #googleTranslate:from:to:
EditTextView.st
--- 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