Step by Step Procedure to create Language Translator
Hello friends how are you, Today in this post "Language Translator in python" i am going to teach you how you can create your own Language translator using 4 lines of code only. If you are a computer science students or teacher and want to learn something interesting in programming then just go through this post. This can also be a simple and interesting project for you.
Language translator is one of the most used software now a days because in most of the cases we have to translate one language into another as per our requirements. Suppose that you want to make a blogger website and you have good knowledge of Hindi but you are unable to translate your Hindi words into English then in this case you need a translator and we mostly prefer google translator, but if you wan to use google translator then you must have a net connection. Here the most important point about this translator is that you don't need an internet connection to translate one language into another and you can create it using only 4 line of code.
Now i am going to explain it step by step so just go through this post to understand this completely.
If you want to understand this through video then watch this video i have explained it step by step live
Step 1: Install Python : Click here to watch a video on how to install python or Open any browser and type Download Python and click the first link you will get official website of python here you will get a Download button and after clicking on this button you will get exe of latest python version just install it into your system.
Step 2: Install Pycharm | Create Project | Install Library: Click here to watch a single video on How to install Pycharm | Create Project | Install Library or To install Pycharm IDE Open any browser and type Download Pycharm and click the first link you will get official website of Pycharm here you will get a black download button and after clicking on this button you will get an exe of Pycharm , just install it into your system. If you are facing problem to install then watch the above video i have explained step by step.
Step 3: Create Project : Open Pycharm click on File which is in top left of screen and select New Project. Then you will get a screen. Here first you need to select directory of your project and then type a name for your project like "LanguageTranslator" after directory name, and at last click the create button to create this project.
Step 4: Create Python file: To create a python file for coding in your project just right click on project name "LanguageTranslator" and select new and click on Python File , you will get popup screen in which you have to type a name like "Program" for python file and press enter, it will create a python file with name Program.py inside the project LanguageTranslator.
Line 1: import library: Here in this we will import the needed library that convert one Language into another.
#import library from translate import Translator #set language in which you want to translate translator= Translator(to_lang="Chinese") #set message that you want to translate translation = translator.translate("Hello friend How are you?") #print translated message print(translation)
#import library from tkinter import* from translate import Translator from tkinter import ttk #translation def translate(): #get input from user ip=engVariable.get() #get selected langauge langauge=lang.get() #creating variable of Translator translator = Translator(to_lang=langauge) #Translation translation = translator.translate(ip) #set translated message into Label transVariable.set(translation) #creating GUI for Transator root =Tk() #setting window height and width root.geometry("600x200") #setting window background color root["bg"]="#20325B" #setting title of window root.title("Krazy:Language Translator") #creating variable for messages global engVariable global transVariable global lang; engVariable=StringVar() transVariable=StringVar() lang=StringVar() #Entry/Textbox for message/Sentence Entry(root,text="Hello",textvariable=engVariable,font="Arial 12",fg="black",width=42).place(x=80,y=30) #combox for language fontExample = ("Courier", 12, "bold") comboExample = ttk.Combobox(root,textvariable=lang, values=[ "Hindi", "German", "Chinese", "Japanese"], #here you can add many more languages font = fontExample) root.option_add('*TCombobox*Listbox.font', fontExample) comboExample.place(x=80,y=70) #button for translate Button(root,text="Translate",font="Arial 12 bold",width="10",command=translate,bg="orange").place(x=350,y=70) #label for generated/success message Label(root,text="Hello",textvariable=transVariable,font="Arial 12",bg="#20325B",fg="white").place(x=80,y=120) root.mainloop()
0 Comments