Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Tamil word translated into available Google Translate languages
# -*- coding: utf-8 -*-
# (C) 2018 Muthiah Annamalai <>
# This code is shared under public domain.
from import translate
import tamil
import codecs
import json
import sys
def get_translated_words(wrd,tgtLang,client):
if tgtLang == 'ta':
return wrd
en_wrd20 = client.translate(wrd,source_language='ta',target_language=tgtLang)
return en_wrd20['translatedText']
def run():
c = translate.Client()
data = {}
lmap = c.get_languages()
for lang in lmap:
lcode = lang['language']
lname = lang['name']
data[lname] = [get_translated_words(u"தமிழ்",lcode,c),lcode]
for lcode,word in data.items():
print(u"%s %s <%s>"%(word[0],word[1],lcode))
with'tamil_2languages.json','w','utf-8') as fp:
fp.write( json.dumps( data ) )
if __name__ == u"__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment