Posts

Showing posts from August, 2020

Language Translation in PYTHON

googletrans :     googletrans is a free and unlimited Python library that implemented Google Translate API. Installation  : pip install googletrans Starter code (with explanation) : 1. from googletrans import Translator 2. trans = Translator() 3. t = trans.translate("Bom Dia", src = "pt", dest = "en") 4. print(f"Source : {t.src}") 5. print(Destination : {t.dest}") 6. print(" {t.origin} --> {t.text}") Explanation : 1. Importing "Translator" function from googletrans library. 2. Making a "trans" object for "Translator()" class. 3. ".translate" is the function used for translating a given string to destination language.   "Bom Dia" is the string to be translated, in "src" attribute source language's code (i.e. the language of given string) and in "dest" attribute, destination language code is given. 4. "t.src" returns source language . 5. "t.de