Skip to content
Related Articles

Related Articles

Improve Article

Language Detection in Python using Tkinter

  • Last Updated : 25 Feb, 2021

Prerequisite: Tkinter

In this article, we will learn about language detection Using Python in Tkinter. In Simple Words, language identification is the problem of determining which natural language given content is in.

Modules Used

  • Tkinter module is used in Python to create GUI based interfaces.
  • For Language detection, we will use the langdetect Module. langdetect Module is a port of Google’s language-detection library that supports 55 languages. This module doesn’t come with Python’s standard utility modules. So, it is needed to be installed externally. To install this type the below command in the terminal.
pip install langdetect
  • The detected language output is coming in code, it is not displaying the language name. Here we will use languages Class From the iso-639 Module. This Module is used for converting language code into language name. To install run the command given below:
pip install iso-639


  • Import module
  • Create window
  • Add button
  • Add mechanism to detect language
  • Add mechanism to translate code
  • Execute code



# Import Module
from tkinter import *
from langdetect import *
from iso639 import languages
# Create Object
root = Tk()
# Set geometry
def language_detection():
    text = T.get("1.0", 'end-1c')
    # Get Language code
    language_code = languages.get(alpha2=detect(text))
    l_d.config(text="Language Detected:- "
# Text Box
T = Text(root)
# label
l_d = Label(root, text="Language Detected:- ")
# Button
Button(root, text='Detect Language', command=language_detection).pack(pady=10)
# Execute Mainloop


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :