Language Translator by Python

Hari Pranesh M
3 min readNov 22, 2021

Python Language Translator — Instantly translate letters, words, and phrases between languages.
Translation allows individuals from different parts of the world to communicate. It allows people to communicate in a meaningful way from one language to another.

Language Translator:
A language translator, often known as a text translator, is a tool that allows you to convert text, words, and phrases from one language to another. It functions similarly to a dictionary, allowing us to translate text.
The objective of this project is to utilize a button to decipher content from one dialect to any other dialect in genuine time. The Tkinter and googletrans libraries will be used to create this project.
The user submits text in any language and has it translated into any other language by selecting the output language. The text is also pronounced by our language translator.

Project Prerequisites:

We’ll utilize the essential concepts of Python, Tkinter, and GoogleTrans libraries to complete this extend.

Tkinter is a well-known Python GUI library. The ttk module provides access to the Tk widget set.

GoogleTrans is a text translation module. We import the GoogleTrans Translator, which is used to perform translations. We also import LANGUAGES from googletrans, which is a Python dictionary that includes all supported languages.

The Text Translator Python Project is built in the following steps:
Import the modules you’ll need
Import the modules you’ll need
Make a window for your display
Create a text widget with input and output
Create a Combobox to choose a language
Define the function
Make a translation button.

  1. Import Modules:

We import the ttk and Translator modules from the tkinter library, as well as the LANGUAGES modules from the googletrans library.

2. Make a window for the display:
Tk() established a window by initialising tkinter.
geometry() sets the window’s width and height resizable (0,0) set the window’s fixed dimensions. bg = to change the colour of the background
title() is used to change the window’s title. The Label() widget is used to show one or more lines of text that users cannot change. root refers to the window text that is displayed on the label font in which the text is written in a pack organised widget in block.

3. Make a text input-output widget.
The code over creates two text widgets, one for entering content and one for showing translated content.

For many text lines, the Text() widget is utilised. wrap = WORD wraps the line at the end of the last word that fits. padx adds a little more space to the widget’s left and right sides. pady increases the amount of space at the top and bottom of the page.

4. Create a Combobox to choose the language.
Users can select a different language for both data input and data translation.

In the form of a list, language retrieves all of the values from the ‘LANGUAGES’ dictionary. The Combobox() widget belongs to the ttk modules class. It’s a multi-value drop-down list that only shows one item at a time. Comboboxes are excellent for selecting one choice from a list of numerous.

5. Make a function definition
The Translate function will translate and output the message. src returns the language that was chosen as the input text language. dest returns the language to be translated, whereas text returns the user’s input text.
“1.0” indicates that the input should be read from line one to zero characters. Reading the text till the finish is reached is what the END portion signifies. translator = Translator() is a method for creating a Translator object.

6. Add a translate button to your website.
When we click the Translation button, the translate function is invoked.

Our window’s Button() widget was utilised to display a button.

When we click the button, command is called. activebackground specifies the colour of the button’s background when it is active root. When we wish to run our application, we use the mainloop() method.

Summary:
The Language Translator python project has been completed successfully. The tkinter library is being utilized to create the user interface, whereas the googletrans library was utilized to translate from one language to another.

We learnt how to translate text, make Comboboxes, and buttons widgets, as well as how to send the function to the button. We can create a Language Translator this way.

Naveenkumar_2401

--

--