Revert "fix the cheap unicode escapes in GoogleTranslate"

unicode-escape appears to do bad things to hiragana and probably
all unicode characters that are not unicode escaped. ultimately
it seems that google's responses are not consistent.

back to the drawing board.

This reverts commit 40888869b0.
This commit is contained in:
Brian S. Stephan 2011-01-07 17:11:00 -06:00
parent 02b3266b46
commit 3333fe125e
2 changed files with 9 additions and 2 deletions

1
TODO
View File

@ -10,6 +10,7 @@ dr.botzo --- TODO
* obligatory info command
* settle on docstrings: http://www.python.org/dev/peps/pep-0257/
* voice survivor --- track how long users have voice, score them somehow
* fix the cheap unicode escapes in GoogleTranslate
* periodic reconnects when disconnected/split
* move the non-IRC things out of IrcAdmin
* into DrBotIRC?

View File

@ -51,8 +51,14 @@ class GoogleTranslate(Module):
end_idx = translation.find('"}, "')
translation = translation[:end_idx]
# convert escaped unicode
translation = translation.decode('unicode-escape', 'ignore')
# do some text conversion
translation = translation.replace('\\u0026quot;', '"')
translation = translation.replace('\\u0026amp;', '&')
translation = translation.replace('\\u003c', '<')
translation = translation.replace('\\u0026lt;', '<')
translation = translation.replace('\\u003e', '>')
translation = translation.replace('\\u0026gt;', '>')
translation = translation.replace('\\u0026#39;', '\'')
return self.reply(connection, replypath, translation)