terryyin / terryyin/translate-python

Discord bot Not translating

Open
#112 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
759
Forks
152
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the official example and the Discord-bot call with a DeepL free API key. Read translate/providers/deepl.py, especially get_translation, alongside the reported JSON parsing and missing translations errors. Done means the DeepL provider translates successfully or reports the API failure clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.