Victor Gavro committed 241a089

Fixed bug related to word meta data returned by google if only one word was specified

Comments (0)

Files changed (1)

     qs = (
         #('anno', '3'), #wtf? annotation?
-        #If sentences more than 1 it returns original after translation.
+        #If anno=3 and sentences more than 1 it returns original before each
+        #sentence. If anno!=3 it returns some meta data as last argument if
+        #only one word was specified.
         #NOTE: this isn't happening from official clients for some reason.
         #('client', 'te'), #google javascript translator
         resp_cont =
     result = json.loads(resp_cont.decode('string-escape'))
+    if isinstance(result, list) and isinstance(result[-1], list):
+        #excluding word meta, if any (see anno=3 description above).
+        result = result[:-1]
     if not source_language:
         #return detected source language as last element if it wasn't specified
         result, source_language = result[:-1], result[-1]
-    elif len(text) == 1:
+    elif isinstance(result, basestring):
         #this isn't json list, just plain text
         result = (result,)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.