Answer the question
In order to leave comments, you need to log in
Why doesn't it translate?
#-*- coding: utf-8 -*-
from Translate import Translater
import config
tr = Translater(config.API_KEY)
print(tr.translate('hello', 'ru'))
#-*- coding: utf-8 -*-
from yandex.Translater import Translater as MainTranslater
from langdetect import detect
class Translater:
def __init__(self, APIKEY):
self.tr = MainTranslater()
self.tr.set_key(APIKEY)
def translate(self, text, langTo):
self.tr.set_from_lang(detect(text))
self.tr.set_to_lang(langTo)
self.tr.set_text(text)
return self.tr.translate()
raceback (most recent call last):
File "c:/Users/Ilya/Desktop/Translator/main.py", line 7, in <module>
print(tr.translate('hello', 'ru'))
File "c:\Users\Ilya\Desktop\Translator\Translate.py", line 14, in translate
return self.tr.translate()
File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\yandex\Translater.py", line 209, in translate
raise TranslaterError('Failed to translate text! {0}'.format(response.reason))
yandex.Translater.TranslaterError: Failed to translate text! Forbidden
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question