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

example() not working #77

Open
Faizan-E-Mustafa opened this issue Feb 15, 2023 · 1 comment
Open

example() not working #77

Faizan-E-Mustafa opened this issue Feb 15, 2023 · 1 comment

Comments

@Faizan-E-Mustafa
Copy link

The example function is not working. First, I use the following code

from translatepy import Translator
translate = Translator()

print(translate.example("Hello", "German", "English"))

which gives the following error.

Traceback (most recent call last):
  File "C:\Users\femustafa\Desktop\Language app\main.py", line 81, in <module>
    print(translate.example("Hello", "German", "English"))
  File "C:\Users\femustafa\Desktop\Language app\.venv\lib\site-packages\translatepy\translate.py", line 363, in example
    raise NoResult("No service has returned a valid result")
translatepy.exceptions.NoResult: No service has returned a valid result

As example function is not implemented for all translators. I just use Bing translator

from translatepy.translators.bing import BingTranslate
translate = BingTranslate()

print(translate.example("Hello", "German", "English"))

which gives the following error.

Traceback (most recent call last):
  File "C:\Users\femustafa\Desktop\Language app\main.py", line 81, in <module>
    print(translate.translate("Hello", "German", "English"))
  File "C:\Users\femustafa\Desktop\Language app\.venv\lib\site-packages\translatepy\translators\base.py", line 110, in translate 
    source_language, translation = self._translate(text, dest_code, source_code)
  File "C:\Users\femustafa\Desktop\Language app\.venv\lib\site-packages\translatepy\translators\bing.py", line 156, in _translate    response = self.session_manager.send("https://www.bing.com/ttranslatev3", data={'text': text, 'fromLang': source_language, 'to': destination_language})
  File "C:\Users\femustafa\Desktop\Language app\.venv\lib\site-packages\translatepy\translators\bing.py", line 135, in send      
    raise BingTranslateException(status_code)
translatepy.translators.bing.BingTranslateException: 205 | Unknown error. Error code: 205

Am i doing something wrong? . Your help will be appreciated.

@ZhymabekRoman
Copy link
Contributor

Yes, this is a problem that we should work on. Some thoughts about the example method refactor is there: #62

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

2 participants