-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
24 lines (18 loc) · 764 Bytes
/
main.py
File metadata and controls
24 lines (18 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from tabulate import tabulate
from googletrans import Translator
class Simple_Translator(object):
def __init__(self, sentence, language):
self.sentence = sentence
self.language = language
self.translator = Translator()
def translation(self):
translation = self.translator.translate(self.sentence, dest=self.language)
data = [["Original Sentence: ", "Translated Sentence: "], [self.sentence, str(translation.text)]]
return tabulate(data, headers="firstrow", tablefmt="fancy_grid")
def __str__(self):
return self.translation()
if __name__ == '__main__':
sentence1 = input("Enter the string to translate = ")
os.system("cls")
print(Simple_Translator(sentence1, "en"))