Sunday, November 23, 2025
HomeLanguagesLanguage Detection in Python using Tkinter

Language Detection in Python using Tkinter

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

Approach

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

Program:

Python3




# Import Module
from tkinter import *
from langdetect import *
from iso639 import languages
  
# Create Object
root = Tk()
  
# Set geometry
root.geometry("400x500")
  
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:- "+language_code.name)
  
  
# Text Box
T = Text(root)
T.pack()
  
# label
l_d = Label(root, text="Language Detected:- ")
l_d.pack(pady=10)
  
# Button
Button(root, text='Detect Language', command=language_detection).pack(pady=10)
  
# Execute Mainloop
root.mainloop()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32410 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6909 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6865 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS