paint-brush
Introductory Guide to Automatic Language Translation in Pythonby@kalebujordan
381 reads
381 reads

Introductory Guide to Automatic Language Translation in Python

by Kalebu Jordan October 11th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Kalebu Jordan is a Mechatronics engineer | Pro Python Developer | AI Enthusiast. I'm going to share with you guys how to automatically perform **language translation** in Python programming. Language translation is concerned with translating textual data from one language to textual data into another language. There are several libraries in Python for performing automatic language translation, below are some of those libraries. Almost all of them are using Google Translate API. In this tutorial I will guide you to build an Automatic Language Translator using the Python programming language.
featured image - Introductory Guide to Automatic Language Translation in Python
Kalebu Jordan  HackerNoon profile picture

Today, I'm going to share with you guys how to automatically perform **language translation** in Python programming.

Language translation is concerned with translating textual data from one language to textual data into another language.

This is usually done in such a way the same message can be conveyed to different people speaking different languages .

In this tutorial, I will guide you to build an Automatic Language Translator using the Python programming language.

Once you understand this, you will be able to use Python to build a language translator with specifics to your use case.

Python Libraries

There are several libraries in Python for performing automatic 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 your personal projects involving language translation.

goslate Installation

$ 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"

googletrans Installation

$ 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'

TextBlob Installation

$ 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 get more tutorial like this .

If you find it useful don't forget to like it and share with your fellow developers.

Also published at https://kalebujordan.com/python-language-translation/