Commit a817891d authored by Michal Čihař's avatar Michal Čihař

Fix MyMemory response handling

The problem is that we try to escape \r inside of the strings and that
fails if it's outside of the string.

Fixes #941
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 65c2a767
...@@ -104,7 +104,7 @@ class MachineTranslation(object): ...@@ -104,7 +104,7 @@ class MachineTranslation(object):
if text.startswith('\xef\xbb\xbf'): if text.startswith('\xef\xbb\xbf'):
text = text.decode('UTF-8-sig') text = text.decode('UTF-8-sig')
# Replace literal \t # Replace literal \t
text = text.replace( text = text.strip().replace(
'\t', '\\t' '\t', '\\t'
).replace( ).replace(
'\r', '\\r' '\r', '\\r'
......
...@@ -59,6 +59,7 @@ GLOSBE_JSON = u''' ...@@ -59,6 +59,7 @@ GLOSBE_JSON = u'''
} }
'''.encode('utf-8') '''.encode('utf-8')
MYMEMORY_JSON = u''' MYMEMORY_JSON = u'''
\r\n
{"responseData":{"translatedText":"svět"},"responseDetails":"", {"responseData":{"translatedText":"svět"},"responseDetails":"",
"responseStatus":200, "responseStatus":200,
"matches":[ "matches":[
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment