Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bf7bf2b

Browse files
Merge pull request avinashkranjan#592 from Ayushjain2205/translator_gui
Translator gui
2 parents 60b3532 + f5c0aab commit bf7bf2b

File tree

3 files changed

+223
-0
lines changed

3 files changed

+223
-0
lines changed

‎Translator-GUI/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Translation Script with GUI
2+
Running this Script would open up a translator with GUI which can be used to translate one language to another
3+
4+
## Setup instructions
5+
In order to run this script, you need to have Python and pip installed on your system. After you're done installing Python and pip, run the following command from your terminal to install the requirements from the same folder (directory) of the project.
6+
```
7+
pip install -r requirements.txt
8+
```
9+
10+
After satisfying all the requirements for the project, Open the terminal in the project folder and run
11+
```
12+
python translator.py
13+
```
14+
or
15+
```
16+
python3 translator.py
17+
```
18+
depending upon the python version. Make sure that you are running the command from the same virtual environment in which the required modules are installed.
19+
20+
## Output
21+
![Sample pic of the Translator GUI](https://i.postimg.cc/HnJJWnKq/translator.png)
22+
23+
## Author
24+
[Ayush Jain](https://github.com/Ayushjain2205)

‎Translator-GUI/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
googletrans==3.1.0a0

‎Translator-GUI/translator.py

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
from tkinter import *
2+
import tkinter as tk
3+
from tkinter import ttk
4+
from googletrans import Translator
5+
from tkinter import messagebox
6+
7+
# Creating Tkinter Scaffold
8+
root = tk.Tk()
9+
root.title('Langauge Translator')
10+
root.geometry('530x330')
11+
root.maxsize(530, 330)
12+
root.minsize(530, 330)
13+
14+
# Function to translate using the translator package
15+
def translate():
16+
language_1 = t1.get("1.0", "end-1c")
17+
cl = choose_langauge.get()
18+
19+
if language_1 == '':
20+
messagebox.showerror('Language Translator', 'please fill the box')
21+
else:
22+
t2.delete(1.0, 'end')
23+
translator = Translator()
24+
output = translator.translate(language_1, dest=cl)
25+
t2.insert('end', output.text)
26+
27+
28+
# Function to clear the input fields
29+
def clear():
30+
t1.delete(1.0, 'end')
31+
t2.delete(1.0, 'end')
32+
33+
# SelectBox 1 for auto detected language
34+
auto_detect_language = tk.StringVar()
35+
auto_detect = ttk.Combobox(
36+
root,
37+
width=20,
38+
textvariable=auto_detect_language,
39+
state='readonly',
40+
font=('verdana', 10, 'bold'),
41+
)
42+
43+
auto_detect['values'] = ('Auto Detect', )
44+
45+
auto_detect.place(x=30, y=70)
46+
auto_detect.current(0)
47+
48+
# SelectBox 2 for selected language
49+
language_selected = tk.StringVar()
50+
choose_langauge = ttk.Combobox(root,
51+
width=20,
52+
textvariable=language_selected,
53+
state='readonly',
54+
font=('verdana', 10, 'bold'))
55+
56+
# List of available language options for translation
57+
choose_langauge['values'] = (
58+
'Afrikaans',
59+
'Albanian',
60+
'Arabic',
61+
'Armenian',
62+
' Azerbaijani',
63+
'Basque',
64+
'Belarusian',
65+
'Bengali',
66+
'Bosnian',
67+
'Bulgarian',
68+
' Catalan',
69+
'Cebuano',
70+
'Chichewa',
71+
'Chinese',
72+
'Corsican',
73+
'Croatian',
74+
' Czech',
75+
'Danish',
76+
'Dutch',
77+
'English',
78+
'Esperanto',
79+
'Estonian',
80+
'Filipino',
81+
'Finnish',
82+
'French',
83+
'Frisian',
84+
'Galician',
85+
'Georgian',
86+
'German',
87+
'Greek',
88+
'Gujarati',
89+
'Haitian Creole',
90+
'Hausa',
91+
'Hawaiian',
92+
'Hebrew',
93+
'Hindi',
94+
'Hmong',
95+
'Hungarian',
96+
'Icelandic',
97+
'Igbo',
98+
'Indonesian',
99+
'Irish',
100+
'Italian',
101+
'Japanese',
102+
'Javanese',
103+
'Kannada',
104+
'Kazakh',
105+
'Khmer',
106+
'Kinyarwanda',
107+
'Korean',
108+
'Kurdish',
109+
'Kyrgyz',
110+
'Lao',
111+
'Latin',
112+
'Latvian',
113+
'Lithuanian',
114+
'Luxembourgish',
115+
'Macedonian',
116+
'Malagasy',
117+
'Malay',
118+
'Malayalam',
119+
'Maltese',
120+
'Maori',
121+
'Marathi',
122+
'Mongolian',
123+
'Myanmar',
124+
'Nepali',
125+
'Norwegian'
126+
'Odia',
127+
'Pashto',
128+
'Persian',
129+
'Polish',
130+
'Portuguese',
131+
'Punjabi',
132+
'Romanian',
133+
'Russian',
134+
'Samoan',
135+
'Scots Gaelic',
136+
'Serbian',
137+
'Sesotho',
138+
'Shona',
139+
'Sindhi',
140+
'Sinhala',
141+
'Slovak',
142+
'Slovenian',
143+
'Somali',
144+
'Spanish',
145+
'Sundanese',
146+
'Swahili',
147+
'Swedish',
148+
'Tajik',
149+
'Tamil',
150+
'Tatar',
151+
'Telugu',
152+
'Thai',
153+
'Turkish',
154+
'Turkmen',
155+
'Ukrainian',
156+
'Urdu',
157+
'Uyghur',
158+
'Uzbek',
159+
'Vietnamese',
160+
'Welsh',
161+
'Xhosa'
162+
'Yiddish',
163+
'Yoruba',
164+
'Zulu',
165+
)
166+
167+
choose_langauge.place(x=290, y=70)
168+
choose_langauge.current(0)
169+
170+
# To store Input Text
171+
t1 = Text(root, width=30, height=10, borderwidth=5, relief=RIDGE)
172+
t1.place(x=10, y=100)
173+
174+
# To store translated Text
175+
t2 = Text(root, width=30, height=10, borderwidth=5, relief=RIDGE)
176+
t2.place(x=260, y=100)
177+
178+
button = Button(root,
179+
text="Translate",
180+
relief=RIDGE,
181+
borderwidth=3,
182+
font=('verdana', 10, 'bold'),
183+
cursor="hand2",
184+
foreground='Green',
185+
command=translate)
186+
button.place(x=150, y=280)
187+
188+
clear = Button(root,
189+
text="Clear",
190+
relief=RIDGE,
191+
borderwidth=3,
192+
font=('verdana', 10, 'bold'),
193+
cursor="hand2",
194+
foreground='Red',
195+
command=clear)
196+
clear.place(x=280, y=280)
197+
198+
root.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /