-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator.py
39 lines (36 loc) · 1.25 KB
/
translator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from translate import Translator
langDict = {'English': "en",
'Spanish': "es",
'Russian': "ru",
'Chinese': "zh",
'Korean': "ko",
'French': "fr",
'Gujarati': "gu",
'Indonesian': "in",
'Irish': "ga",
'Japanese': "ja",
'Punjabi': "pa",
'Tagalog': "tl",
'Urdu': "ur",
'Vietnamese': "vi"}
wordDict = {'English': "English",
'Spanish': "español",
'Russian': "русский",
'Chinese': "中文",
'Korean': "한국어",
'French': "français",
'Gujarati': "ગુજરાતી",
'Indonesian': "bahasa Indonesia",
'Irish': "Gaeilge",
'Japanese': "日本語",
'Punjabi': "ਪੰਜਾਬੀ ਦੇ",
'Tagalog': "tagalog",
'Urdu': "اردو",
'Vietnamese': "Tiếng Việt"}
def transStr(language, phrase):
for l in langDict:
if language == l:
translator = Translator(to_lang=langDict[language])
transword = wordDict[l]
translation = translator.translate(phrase)
print translation + ' ' + transword