Kalebu Jordan

Become a Pro Python Developer

python language translation

Hi guys, in this article I’m going to share with you 3 common ways to do language translation in python using goslate , googletrans , and textblob in python.

what will you build ?

At the end of this article you will have a good grasp of language translation and how can you do it in python using its libraries.

Python-based libraries for language translation

There are several libraries in Python for performing language translation, below are some of those libraries but almost all of them are using Google Translate API.

Just check them out in detail and choose which one you like the most to use in your personal projects involving language translation.



$ pip install goslate 

goslate will automatically detect your primary language of text and then translate it to secondary language you specify.

During specifying language you use ISO 639-1 codes you can find them here

Example of Usage (gos.py)]

>>>import goslate
>>>primary_text = 'Love you a lot '
>>>gs = goslate.Goslate()
>>>gs.translate(primary_text, 'fr')
"Je t'aime beaucoup"



$ pip install googletrans

Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate.

For instance Let’s translate “This site is awesome ” to swahili language, also here language is represented in ISO 639-1

Example of Usage

>>> text = 'This site is awesome'
>>> from googletrans import Translator
>>> translator = Translator()
>>> translator.translate(text , dest ='sw').text
'Tovuti hii ni ajabu'



$ pip install -U textblob
$ python -m textblob.download_corpora

TextBlob is a Python (2 and 3) library for processing textual data. It provides a simple API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, and more.

Example of Usage

>>> from textblob import TextBlob
>>> blob = TextBlob('comment ca va ?')
>>> blob.translate(to='en')
TextBlob("How is it going ?")

I hope you find this tutorial interesting, don’t forget to subscribe to stay updated on upcoming Python tutorial.

I also recommend you to read this;

In case of anything drop it in the comment box below, I will get back to you ASAP.

2 thoughts on “3 ways to do language translation in Python

Leave a Reply


Enjoy this blog? Please spread the word :)