this encode('utf-8')/decode('utf-8') seems to unnecessary and accomplishes nothing?
still haven't figured out how to get around the whole character replace nonsense though
This commit is contained in:
parent
7c4125e099
commit
cb7044e64a
@ -33,9 +33,6 @@ class GoogleTranslate(Module):
|
|||||||
fromlang = whats[1]
|
fromlang = whats[1]
|
||||||
tolang = whats[2]
|
tolang = whats[2]
|
||||||
text = ' '.join(whats[3:])
|
text = ' '.join(whats[3:])
|
||||||
try:
|
|
||||||
text = text.encode('utf-8')
|
|
||||||
except UnicodeDecodeError: pass
|
|
||||||
|
|
||||||
langpair = '%s|%s' % (fromlang, tolang)
|
langpair = '%s|%s' % (fromlang, tolang)
|
||||||
gt_url = 'http://ajax.googleapis.com/ajax/services/language/translate'
|
gt_url = 'http://ajax.googleapis.com/ajax/services/language/translate'
|
||||||
@ -46,9 +43,6 @@ class GoogleTranslate(Module):
|
|||||||
end_idx = translation.find('"}, "')
|
end_idx = translation.find('"}, "')
|
||||||
translation = translation[:end_idx]
|
translation = translation[:end_idx]
|
||||||
|
|
||||||
# decode the string, since it may include unicode. it will be encoded later.
|
|
||||||
translation = translation.decode('utf-8')
|
|
||||||
|
|
||||||
# do some text conversion
|
# do some text conversion
|
||||||
translation = translation.replace('\\u0026quot;', '"')
|
translation = translation.replace('\\u0026quot;', '"')
|
||||||
translation = translation.replace('\\u0026amp;', '&')
|
translation = translation.replace('\\u0026amp;', '&')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user