1

Topic: To bypass restriction on an amount of characters and connections Google Translate API

Is available about such code. Does not translate the big piece of the text as I understand restriction of 5000 or less characters. Plus restriction on number of connections. Whether probably to bypass?
[spoiler]

class MainWindow (QMainWindow, Ui_MainWindow):
def __ init __ (self, *args, ** kwargs):
super (MainWindow, self). __ init __ (*args, ** kwargs)
self.setupUi (self)
self.translator = Translator ()
self.destTextEdit.setReadOnly (True)
if GOOGLE_TRANSLATE_AVAILABLE:
self.srcLanguage.addItems (LANGUAGES.keys ())
self.srcLanguage.currentTextChanged [str].connect (self.update_src_language)
self.srcLanguage.setCurrentText (' English ')
else:
self.srcLanguage.hide ()
self.translateButton.pressed.connect (self.translate)
self.show ()
def update_src_language (self, l):
self.language_src = LANGUAGES [l]
def google_translate (self, text):
params = dict (
dest ='en ';
text=text
)
if self.language_src:
params [' src '] = self.language_src
try:
tr = self.translator.translate (** params)
except Exception:
self.destTextEdit.setPlainText (' Google translate error :(. Try translating from English ')
return False
else:
return tr.text
def translate (self):
# Perform pre-translation to English via Google Translate.
# if self.language_src! = ' en ':
text = self.google_translate (self.srcTextEdit.toPlainText ())
if not text:
return False
data = text
if ' error ' in data:
self.destTextEdit.setPlainText ("%s\n\n%s" % (data [' error '] [' message '], text))
else:
self.destTextEdit.setPlainText (data)
if __ name __ == ' __ main __ ':
app = QApplication ([])
window = MainWindow ()
app.exec _ ()

[/spoiler]