A few minor changes to previous GoogleTranslate commit
This commit is contained in:
parent
6f2ae757be
commit
257562f0d0
@ -52,11 +52,11 @@ class GoogleTranslate(Module):
|
||||
|
||||
# do some text conversion
|
||||
for i in re.findall('\u(\w{4})', translation):
|
||||
replacement = unichr(int(i, 16))
|
||||
translation = translation.replace('\u' + i, replacement)
|
||||
translation = translation.replace('\u' + i, unichr(int(i, 16)))
|
||||
|
||||
for i in re.findall('&(#)?(x)?(\w+?);', translation):
|
||||
replacement = i[2]
|
||||
original = '&' + i[0] + i[1] + i[2] + ';'
|
||||
replacement = original
|
||||
if i[0] == "#":
|
||||
if i[1] == 'x':
|
||||
replacement = unichr(int(i[2], 16))
|
||||
@ -65,7 +65,7 @@ class GoogleTranslate(Module):
|
||||
else:
|
||||
cp = name2codepoint.get(i[2])
|
||||
replacement = unichr(cp)
|
||||
translation = translation.replace('&' + i[0] + i[1] + i[2] + ';', replacement)
|
||||
translation = translation.replace(original, replacement)
|
||||
|
||||
translation = translation.replace('\\\\', '\\')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user