xinebf / google-translate-for-goldendict

Add Google translate to GoldenDict
GNU General Public License v3.0
274 stars 58 forks source link

Translation doesn't appear #1

Closed darnn closed 6 years ago

darnn commented 6 years ago

Hi! I can't seem to get this to work, either in Goldendict or just from the command line. I have Python 3.7 installed, and have installed requests. In Goldendict, I get the following error: Query error: The program has returned exit code 1. Traceback (most recent call last): File "D:\gt\googletranslate.py", line 43, in gtrans() File "D:\gt\googletranslate.py", line 37, in gtrans print(result.encode('gbk', 'ignore').decode('gbk')) File "D:\Python\Python37-32\lib\encodings\cp1255.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 33-34: character maps to

xinebf commented 6 years ago

I am using Python 3.7 on Windows 10, there is no problem with the translation of Goldendict, which one is the target language you are using.

darnn commented 6 years ago

Hebrew. I'm using Windows 7 SP1, and the latest Windows build of the Goldendict beta (1.5.0-RC2-311-g15062f7).

darnn commented 6 years ago

Wait, so, I should clarify: I get the above error if I try translating into Chinese (zh-CN). When I try translating into Hebrew (he-IL), I only get the original term I was trying to translate: gt-he-il

xinebf commented 6 years ago

You can replace the two gbk with cp1255 in line 37 of googletranslate.py.

print(result.encode('cp1255', 'ignore').decode('cp1255'))
darnn commented 6 years ago

Ahh, it works! Thank you! I also have a different bug report (or feature request, depending on how you look at it), but I'll open a separate issue.