Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeepL translation fails #103

Open
BenisonSam opened this issue Dec 8, 2022 · 0 comments
Open

DeepL translation fails #103

BenisonSam opened this issue Dec 8, 2022 · 0 comments

Comments

@BenisonSam
Copy link

BenisonSam commented Dec 8, 2022

from translate import Translator
translator = Translator(provider='deepl', from_lang='DE', to_lang='EN',
                        secret_access_key='<secret_access_key>')
translator.translate('Ich bin Max Mustermann')

Error Message:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [81], in <cell line: 1>()
----> 1 translator.translate('Ich bin Max Mustermann'')

File C:\devtools\Python\Anaconda3Win\envs\ismll\lib\site-packages\translate\translate.py:45, in Translator.translate(self, text)
     42     return text
     44 text_list = wrap(text, TRANSLATION_API_MAX_LENGHT, replace_whitespace=False)
---> 45 return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)

File C:\devtools\Python\Anaconda3Win\envs\ismll\lib\site-packages\translate\translate.py:45, in <genexpr>(.0)
     42     return text
     44 text_list = wrap(text, TRANSLATION_API_MAX_LENGHT, replace_whitespace=False)
---> 45 return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)

File C:\devtools\Python\Anaconda3Win\envs\ismll\lib\site-packages\translate\providers\deepl.py:48, in DeeplProvider.get_translation(self, text)
     45 if "error" in data:
     46     raise TranslationError(data["error"]["message"])
---> 48 return data["translations"][0]["text"]

KeyError: 'translations'

Can't figure out what's wrong. The API URL seems to be fine here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant