In the following lines, we will learn how to create a simple dictionary in a few lines of Python code. First, we need the
translate is a simple but powerful translation tool written in Python with support for multiple translation providers. It offers integration with Microsoft Translation API, MyMemory API, LibreTranslate, and DeepL’s free and professional APIs.
We can use translate as a module with this command:
$ pip install translate
Now we create some codes that allow us to enter what we have to translate. We will write the following method
def pB_traducoClick(self): try: to_Translate = (self.lE_input.text()) traduzione = t.Translator(to_lang="it") result = traduzione.translate(to_Translate) self.lE_output.setText(result) except: print('Valore nel campo non accettato')
This is the connection diagram:
The value of
to_lang is one of the languages that are available in ISO_639–1 (like “en”, “ja”, “ko”, “pt”, “zh”, “zh-TW”, etc.)
You can choose in this document the language you want.
From here you can find the source codes.