Improve your programming skills

Python googletrans

How to user googletrans

# pip install googletrans
# http://zetcode.com/python/googletrans/
# If we do not specify the source and the destination languages,
# googletrans tries to detect the language and translates it into English.

import googletrans
from googletrans import Translator
print(googletrans.LANGUAGES)

# without language source and destination choose
#translator = Translator()
#translated = translator.translate('jestem najlepszy')
#print(translated.text)

# with language source and destination choose. From polish to english
translator = Translator()
translated = translator.translate('to jest najlepsze szkolenie', src='pl', dest='en')
print(translated.text)

# reverse with translated sentence. Now from english to polish
translated = translator.translate(translated.text, src='en', dest='pl')
print(translated.text)

Leave a comment

Your email address will not be published. Required fields are marked *