terryyin / translate-python

Online translation as a Python module & command line tool. No key, no authentication needed.
MIT License
728 stars 153 forks source link

Discord bot Not translating #112

Open AYMBotBuildersOfficial opened 4 months ago

AYMBotBuildersOfficial commented 4 months ago

I am using translate for a discord bot, and when I put with a deepL free API key, it is not translate and when i did error logging I got An error occurred: Expecting value: line 1 column 1 (char 0)

I tried official given code in the PyPI page but it also not working, it gives error:

_Traceback (most recent call last): File "/home/funz/testing.py", line 9, in translated_text = translator.translate('the book is on the table') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/funz/end/lib/python3.11/site-packages/translate/translate.py", line 45, in translate return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/funz/end/lib/python3.11/site-packages/translate/translate.py", line 45, in return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/funz/end/lib/python3.11/site-packages/translate/providers/deepl.py", line 48, in get_translation return data["translations"][0]["text"]


KeyError: 'translations'_

I think this error might be same reason why bot's script also won't translate.