pypapago icon indicating copy to clipboard operation
pypapago copied to clipboard

KeyError: 'translatedText'

Open BigZapper opened this issue 5 years ago • 1 comments

I have this problem: Traceback (most recent call last): File "sub.py", line 1624, in result = translator.translate(i.content, source='en', target='vi',) File "C:\Python38\lib\site-packages\pypapago\translator.py", line 60, in translate return response.json()['translatedText'] KeyError: 'translatedText'

How to fix it?

BigZapper avatar Apr 21 '20 09:04 BigZapper

please write translator.py on line 59:

if not verbose:
            if 'translatedText' in response.json():
                return response.json()['translatedText']
            else:
                return ''

MineEric64 avatar Apr 27 '20 03:04 MineEric64