#!/usr/bin/python #WERD, is a phonetic transliterator that helps users write english #text but read the same in the chosen Indic font. #Copyright (C) 2007 Atul Nene (www.atulnene.com) # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details at #http://www.gnu.org/licenses/gpl.html . import string from Tkinter import * class FontDict: def __init__(self): #dict of dicts self.fontDictDict = {} #dict for each font supported self.fontDict_Shivaji01 = {} self.fontDict_xdvng = {} self.fontDict_dev2 = {} self.fontDict_uni = {} #init the Shivaji01 font self.fontDict_Shivaji01["a"] = "A" # "A" self.fontDict_Shivaji01["ai"] = "eo" # "eo" self.fontDict_Shivaji01["ai_maatraa"] = "O" # "O" self.fontDict_Shivaji01["b"] = "b" # "b" self.fontDict_Shivaji01["bh"] = "B" # "B" self.fontDict_Shivaji01["bhr"] = "B" + u'\u0060' # "B`" self.fontDict_Shivaji01["ch"] = "c" # "c" self.fontDict_Shivaji01["chandra"] = u'\u005E' # "^" self.fontDict_Shivaji01["chandra_bindu"] = u'\u00D0' # "Ð" self.fontDict_Shivaji01["chha"] = "C" # "C" self.fontDict_Shivaji01["da"] = "d" # "d" self.fontDict_Shivaji01["deerghaviraam"] = u'\u00C8' + u'\u00C8' # "ÈÈ" self.fontDict_Shivaji01["dh"] = "Q" # "Q" self.fontDict_Shivaji01["dnya"] = "&" # "&" self.fontDict_Shivaji01["Da"] = "D" # "D" self.fontDict_Shivaji01["Dha"] = "Z" # "Z" self.fontDict_Shivaji01["e"] = "e" # "e" self.fontDict_Shivaji01["e_maatraa"] = "o" # "o" self.fontDict_Shivaji01["ee"] = u"\u0161" self.fontDict_Shivaji01["ee_velaanti"] = "I" # "I" self.fontDict_Shivaji01["g"] = "g" # "g" self.fontDict_Shivaji01["gh"] = "G" # "G" self.fontDict_Shivaji01["gr"] = "g" + "a" + u'\u0060' # "g`" self.fontDict_Shivaji01["gunile"] = u'\u00D7' # "×" self.fontDict_Shivaji01["h"] = u'\u002A' # ")" self.fontDict_Shivaji01["ha"] = "h" # "h" self.fontDict_Shivaji01["i"] = "[" # "[" self.fontDict_Shivaji01["i_velaanti"] = "i" # "i" self.fontDict_Shivaji01["j"] = "j" # "j" self.fontDict_Shivaji01["jh"] = "J" # "J" self.fontDict_Shivaji01["k"] = "@" # "@" self.fontDict_Shivaji01["ka"] = "k" # "k" self.fontDict_Shivaji01["kaanaa"] = "a" # "a" self.fontDict_Shivaji01["kaawaLaa"] = u'\u002F' self.fontDict_Shivaji01["kh"] = "#" # "#" self.fontDict_Shivaji01["kha"] = "K" # "K" self.fontDict_Shivaji01["ksh"] = "x" # "x" self.fontDict_Shivaji01["kr"] = u'\u00CB' # self.fontDict_Shivaji01["l"] = "l" # "l" self.fontDict_Shivaji01["L"] = "L" # "L" self.fontDict_Shivaji01["m"] = "m" # "m" self.fontDict_Shivaji01["n"] = "n" # "n" self.fontDict_Shivaji01["N"] = "N" # "N" self.fontDict_Shivaji01["om"] = "!" # "!" self.fontDict_Shivaji01["oo"] = "}" # "}" self.fontDict_Shivaji01["oo_maatraa"] = "U" # "U" self.fontDict_Shivaji01["paayamoDyaa"] = u"\u005C" # "\" self.fontDict_Shivaji01["p"] = "P" # "P" self.fontDict_Shivaji01["pa"] = "p" # "p" self.fontDict_Shivaji01["ph"] = "F" # "F" self.fontDict_Shivaji01["pha"] = "f" # "f" self.fontDict_Shivaji01["pra"] = "p" + u"\u0060" # "p`" self.fontDict_Shivaji01["ra"] = "r" # "r" self.fontDict_Shivaji01["rafar"] = u"\u002D" # '-' self.fontDict_Shivaji01["rukar"] = u"\u0052" self.fontDict_Shivaji01["s"] = "s" # "s" self.fontDict_Shivaji01["sh"] = "X" # "X" self.fontDict_Shivaji01["shh"] = "Y" # "Y" self.fontDict_Shivaji01["shr"] = "E" # "E" self.fontDict_Shivaji01["t"] = "%" # "%" self.fontDict_Shivaji01["th"] = "q" # "q" self.fontDict_Shivaji01["tilda"] = "|" # "|" self.fontDict_Shivaji01["timba"] = "M" # "M" self.fontDict_Shivaji01["tr"] = "~" # "~" self.fontDict_Shivaji01["Ta"] = "T" # "T" self.fontDict_Shivaji01["Tha"] = "z" # "z" self.fontDict_Shivaji01["u"] = "]" # "]" self.fontDict_Shivaji01["u_maatraa"] = "u" # "u" self.fontDict_Shivaji01["v"] = "v" # "v" self.fontDict_Shivaji01["y"] = "y" # "y" self.fontDict_Shivaji01["0"] = u'\u0030' # "0" self.fontDict_Shivaji01["1"] = u'\u0031' # "1" self.fontDict_Shivaji01["2"] = u'\u0032' # "2" self.fontDict_Shivaji01["3"] = u'\u0033' # "3" self.fontDict_Shivaji01["4"] = u'\u0034' # "4" self.fontDict_Shivaji01["5"] = u'\u0035' # "5" self.fontDict_Shivaji01["6"] = u'\u0036' # "6" self.fontDict_Shivaji01["7"] = u'\u0037' # "7" self.fontDict_Shivaji01["8"] = u'\u0038' # "8" self.fontDict_Shivaji01["9"] = u'\u0039' # "9" self.fontDict_Shivaji01["."] = "." # "." self.fontDict_Shivaji01[","] = u'\u00B8' # " " self.fontDict_Shivaji01[":"] = u'\u00C1' # "Á" self.fontDict_Shivaji01[";"] = u'\u00C2' # "Â" self.fontDict_Shivaji01["?"] = u'\u00C6' # "Æ" self.fontDict_Shivaji01["*"] = u'\u00B5' # "µ" self.fontDict_Shivaji01["^"] = u'\u00D8' # "Ø" self.fontDict_Shivaji01["'"] = "'" # "'" self.fontDict_Shivaji01['"'] = '"' # """ self.fontDict_Shivaji01['%'] = u'\u0089' # "‰" self.fontDict_Shivaji01['$'] = u'\u00C9' + u'\u00BA' # "ɺ" self.fontDict_Shivaji01['-'] = u'\u00B9' # "¹" self.fontDict_Shivaji01['+'] = u'\u00B1' # "±" self.fontDict_Shivaji01['='] = u'\u00C4' # "Ä" self.fontDict_Shivaji01['@'] = u'\u00C7' # "Ç" self.fontDict_Shivaji01['`'] = u'\u00AA' # "ª" self.fontDict_Shivaji01['#'] = u'\u0021' # "!" self.fontDict_Shivaji01['&'] = u'\u0021' # "!" self.fontDict_Shivaji01['('] = u'\u00B3' # "³" self.fontDict_Shivaji01[')'] = u'\u00B4' # "´" self.fontDict_Shivaji01['['] = u'\u00A4' # "¤" self.fontDict_Shivaji01[']'] = u'\u00A5' # "¥" self.fontDict_Shivaji01['{'] = u'\u00A1' # "¡" self.fontDict_Shivaji01['}'] = u'\u00A3' # "£" self.fontDict_Shivaji01['<'] = u'\u00C3' # "Ã" self.fontDict_Shivaji01['>'] = u'\u00C5' # "Å" self.fontDict_Shivaji01['/'] = u'\u00C0' # "À" self.fontDict_Shivaji01['\\'] = u'\u00D2' # "Ò" self.fontDict_Shivaji01['|'] = u'\u00C8' # "È" self.fontDict_Shivaji01['!'] = u'\u00D1' # "Ñ" #self.fontDict_Shivaji01[' '] = " " self.fontDict_Shivaji01[' '] = " " self.fontDictDict["Shivaji01"] = self.fontDict_Shivaji01 self.fontDictDict["Shivaji02"] = self.fontDict_Shivaji01 self.fontDictDict["Shivaji05"] = self.fontDict_Shivaji01 #init the xdvng font self.fontDict_xdvng["a"] = u'\u0041' #"A" self.fontDict_xdvng["ai"] = u'\u004F' + u'\u00F0' #"Oð" self.fontDict_xdvng["ai_maatraa"] = u'\u00F2' #"ò" self.fontDict_xdvng["b"] = u'\u0062' #"b" self.fontDict_xdvng["bh"] = u'\u0042' #"B" self.fontDict_xdvng["bhr"] = u'\u0042' + u'\u00D2' #"BÒ" self.fontDict_xdvng["ch"] = u'\u0063' #"c" self.fontDict_xdvng["chandra"] = u'\u00F4' #"ô" self.fontDict_xdvng["chandra_bindu"] = u'\u00FA' #"ú" self.fontDict_xdvng["chha"] = u'\u0043' #"C" self.fontDict_xdvng["da"] = u'\u0064' #"d" self.fontDict_xdvng["deerghaviraam"] = u'\u002F' #"/" self.fontDict_xdvng["dh"] = u'\u0044' #"D" self.fontDict_xdvng["dnya"] = u'\u0077' #"w" self.fontDict_xdvng["Da"] = u'\u0052' #"R" self.fontDict_xdvng["Dha"] = u'\u005A' #"Z" self.fontDict_xdvng["e"] = u'\u004F' #"O" self.fontDict_xdvng["e_maatraa"] = u'\u00F1' #"ñ" self.fontDict_xdvng["ee"] = u'\u0049' #"I" self.fontDict_xdvng["ee_velaanti"] = u'\u0069' #"i" self.fontDict_xdvng["g"] = u'\u0067' #"g" self.fontDict_xdvng["gh"] = u'\u0047' #"G" self.fontDict_xdvng["gr"] = u'\u0067' + u'\u0061' + u'\u00D2' #"gÒ" self.fontDict_xdvng["gunile"] = u'\u0021' #"!" self.fontDict_xdvng["h"] = u'\u0068' + u'\u00CE' #"hÎ" self.fontDict_xdvng["ha"] = u'\u0068' #"h" self.fontDict_xdvng["i"] = u'\u0045' #"E" self.fontDict_xdvng["i_velaanti"] = u'\u0065' #"e" self.fontDict_xdvng["j"] = u'\u006A' #"j" self.fontDict_xdvng["jh"] = u'\u004A' #"J" self.fontDict_xdvng["k"] = u'\u0056' #"V" self.fontDict_xdvng["ka"] = u'\u006B' #"k" self.fontDict_xdvng["kaanaa"] = u'\u0061' #"a" self.fontDict_xdvng["kaawaLaa"] = u'\u00D6' #"a" self.fontDict_xdvng["kh"] = u'\u004B' #"K" self.fontDict_xdvng["kha"] = u'\u004B' +u'\u0061' #"Ka" self.fontDict_xdvng["ksh"] = u'\u0078' #"x" self.fontDict_xdvng["kr"] = u'\u006B' + u'\u00D2' self.fontDict_xdvng["l"] = u'\u006C' #"l" self.fontDict_xdvng["L"] = u'\u004D' #"M" self.fontDict_xdvng["m"] = u'\u006D' #"m" self.fontDict_xdvng["n"] = u'\u006E' #"n" self.fontDict_xdvng["N"] = u'\u004E' #"N" self.fontDict_xdvng["om"] = u'\u0021' #"!" self.fontDict_xdvng["oo"] = u'\u0055' #"U" self.fontDict_xdvng["oo_maatraa"] = u'\u00DC' #"Ü" self.fontDict_xdvng["paayamoDyaa"] = u'\u00CE' #"Î" self.fontDict_xdvng["p"] = u'\u0070' #"p" self.fontDict_xdvng["pa"] = u'\u0070' + u'\u0061' #"pa" self.fontDict_xdvng["ph"] = u'\u005B' #"[" self.fontDict_xdvng["pha"] = u'\u0050' #"P" self.fontDict_xdvng["pra"] = u'\u0070' + u'\u0061' + u'\u00D2' #"paÒ" self.fontDict_xdvng["ra"] = u'\u0072' #"r" self.fontDict_xdvng["rafar"] = u'\u00FC' #"ü" self.fontDict_xdvng["rukar"] = u'\u00E0' #"ü" self.fontDict_xdvng["s"] = u'\u0073' #"s" self.fontDict_xdvng["sh"] = u'\u0053' #"S" self.fontDict_xdvng["shh"] = u'\u005C' #"\" self.fontDict_xdvng["shr"] = u'\u00C2' #"Â" self.fontDict_xdvng["t"] = u'\u0074' #"t" self.fontDict_xdvng["th"] = u'\u0054' #"T" self.fontDict_xdvng["tilda"] = u'\u007C' #"|" self.fontDict_xdvng["timba"] = u'\u007E' #"~" self.fontDict_xdvng["tr"] = u'\u002A' + u'\u0061' #"*a" self.fontDict_xdvng["Ta"] = u'\u0058' #"X" self.fontDict_xdvng["Tha"] = u'\u0059' #"Y" self.fontDict_xdvng["u"] = u'\u0075' #"u" self.fontDict_xdvng["u_maatraa"] = u'\u00D8' #"Ø" self.fontDict_xdvng["v"] = u'\u0076' #"v" self.fontDict_xdvng["y"] = u'\u0079' #"y" self.fontDict_xdvng["0"] = u'\u0030' # "0" self.fontDict_xdvng["1"] = u'\u0031' # "1" self.fontDict_xdvng["2"] = u'\u0032' # "2" self.fontDict_xdvng["3"] = u'\u0033' # "3" self.fontDict_xdvng["4"] = u'\u0034' # "4" self.fontDict_xdvng["5"] = u'\u0035' # "5" self.fontDict_xdvng["6"] = u'\u0036' # "6" self.fontDict_xdvng["7"] = u'\u0037' # "7" self.fontDict_xdvng["8"] = u'\u0038' # "8" self.fontDict_xdvng["9"] = u'\u0039' # "9" self.fontDict_xdvng["."] = u'\u002E' #"." self.fontDict_xdvng[","] = u'\u0020' + u'\u00D3' #" Ó" self.fontDict_xdvng[":"] = u'\u0048' #"H" self.fontDict_xdvng[";"] = u'\u0048' #"H" self.fontDict_xdvng["?"] = u'\u0021' #"!" self.fontDict_xdvng["*"] = u'\u0021' #"!" self.fontDict_xdvng["^"] = u'\u0021' #"!" self.fontDict_xdvng["'"] = u'\u0091' #"‘" self.fontDict_xdvng['"'] = u'\u0021' #"!" self.fontDict_xdvng['%'] = u'\u0021' #"!" self.fontDict_xdvng['$'] = u'\u002C' + u'\u0026' #",&" self.fontDict_xdvng['-'] = u'\u0021' #"!" self.fontDict_xdvng['+'] = u'\u0021' #"!" self.fontDict_xdvng['='] = u'\u0021' #"!" self.fontDict_xdvng['@'] = u'\u0021' #"!" self.fontDict_xdvng['`'] = u'\u0091' #"‘" self.fontDict_xdvng['#'] = u'\u0021' #"!" self.fontDict_xdvng['&'] = u'\u0021' #"!" self.fontDict_xdvng['('] = u'\u0021' #"!" self.fontDict_xdvng[')'] = u'\u0021' #"!" self.fontDict_xdvng['['] = u'\u0021' #"!" self.fontDict_xdvng[']'] = u'\u0021' #"!" self.fontDict_xdvng['{'] = u'\u0021' #"!" self.fontDict_xdvng['}'] = u'\u0021' #"!" self.fontDict_xdvng['<'] = u'\u0021' #"!" self.fontDict_xdvng['>'] = u'\u0021' #"!" self.fontDict_xdvng['/'] = u'\u0021' #"!" self.fontDict_xdvng['\\'] = u'\u0021' #"!" self.fontDict_xdvng['|'] = u'\u002E' #"." self.fontDict_xdvng['!'] = u'\u0021' #"!" self.fontDict_xdvng[' '] = u'\u0020' #" " self.fontDictDict["xdvng"] = self.fontDict_xdvng #init the aakrutidev font self.fontDict_dev2["a"] = u'\u0041' # "A" self.fontDict_dev2["ai"] = u'\u0046' + u'\u00E9' # "Fé" self.fontDict_dev2["ai_maatraa"] = u'\u00EA' # "ê" self.fontDict_dev2["b"] = u'\u00A3' # "£" self.fontDict_dev2["bh"] = u'\u00A4' # "¤" self.fontDict_dev2["bhr"] = u'\u00A4' + u'\u00FE' # "¤#254" self.fontDict_dev2["ch"] = u'\u0074' # "t" self.fontDict_dev2["chandra"] = u'\u00F6' # "ö" self.fontDict_dev2["chandra_bindu"] = u'\u00F7' # "÷" self.fontDict_dev2["chha"] = u'\u004D' # "M" self.fontDict_dev2["da"] = u'\u0058' # "X" self.fontDict_dev2["deerghaviraam"] = u'\u005C' + u'\u005C' # "\\" self.fontDict_dev2["dh"] = u'\u007C' # "|" self.fontDict_dev2["dnya"] = u'\u00B3' + u'\u00EB' # "³ë" self.fontDict_dev2["Da"] = u'\u0053' # "S" self.fontDict_dev2["Dha"] = u'\u0054' # "T" self.fontDict_dev2["e"] = u'\u0046' # "F" self.fontDict_dev2["e_maatraa"] = u'\u00E9' # "é" self.fontDict_dev2["ee"] = u'\u0042' + u'\u00E1' # "Bá" self.fontDict_dev2["ee_velaanti"] = u'\u00ED' # "í" self.fontDict_dev2["g"] = u'\u0072' # "r" self.fontDict_dev2["gh"] = u'\u0073' # "s" self.fontDict_dev2["gr"] = u'\u0072' + u'\u00EB' + u'\u00FE' # "rþ" self.fontDict_dev2["gunile"] = u'\u0178' # "Ÿ" self.fontDict_dev2["h"] = u'\u00AF' # "¯" self.fontDict_dev2["ha"] = u'\u006E' # "n" self.fontDict_dev2["i"] = u'\u0042' # "B" self.fontDict_dev2["i_velaanti"] = u'\u00EC' # "ì" self.fontDict_dev2["j"] = u'\u0075' # "u" self.fontDict_dev2["jh"] = u'\u0076' # "v" self.fontDict_dev2["k"] = u'\u0070' # "p" self.fontDict_dev2["ka"] = u'\u0047' # "G" self.fontDict_dev2["kaanaa"] = u'\u00EB' # "ë" self.fontDict_dev2["kaawaLaa"] = u'\u00DB' # "ë" self.fontDict_dev2["kh"] = u'\u0071' # "q" self.fontDict_dev2["kha"] = u'\u0048' # "H" self.fontDict_dev2["ksh"] = u'\u00B1' # "±" self.fontDict_dev2["kr"] = u'\u0047' + u'\u00FE' self.fontDict_dev2["l"] = u'\u00A8' # "¨" self.fontDict_dev2["L"] = u'\u0068' # "h" self.fontDict_dev2["m"] = u'\u00A5' # "¥" self.fontDict_dev2["n"] = u'\u007E' # "~" self.fontDict_dev2["N"] = u'\u0078' # "x" self.fontDict_dev2["om"] = u'\u00FB' # "û" self.fontDict_dev2["oo"] = u'\u0044' # "D" self.fontDict_dev2["oo_maatraa"] = u'\u00DE' # "Þ" self.fontDict_dev2["paayamoDyaa"] = u'\u00F9' # "ù" self.fontDict_dev2["p"] = u'\u00A1' # "¡" self.fontDict_dev2["pa"] = u'\u005E' # "^" self.fontDict_dev2["ph"] = u'\u00A2' # "¢" self.fontDict_dev2["pha"] = u'\u005F' # "_" self.fontDict_dev2["pra"] = u'\u005E' + u'\u00FE' # "^þ" self.fontDict_dev2["ra"] = u'\u0065' # "e" self.fontDict_dev2["rafar"] = u'\u00E1' # "á" self.fontDict_dev2["rukar"] = u'\u00DC' # "á" self.fontDict_dev2["s"] = u'\u00AE' # "®" self.fontDict_dev2["sh"] = u'\u006A' # "j" self.fontDict_dev2["shh"] = u'\u00AB' # "«" self.fontDict_dev2["shr"] = u'\u00D0' # "Ð" self.fontDict_dev2["t"] = u'\u0079' # "y" self.fontDict_dev2["th"] = u'\u007A' # "z" self.fontDict_dev2["tilda"] = u'\u00FA' # "ú" self.fontDict_dev2["timba"] = u'\u00F8' # "ø" self.fontDict_dev2["tr"] = u'\u00B2' + u'\u00EB' # "²ë" self.fontDict_dev2["Ta"] = u'\u0051' # "Q" self.fontDict_dev2["Tha"] = u'\u0052' # "R" self.fontDict_dev2["u"] = u'\u0043' # "C" self.fontDict_dev2["u_maatraa"] = u'\u00DD' # "Ý" self.fontDict_dev2["v"] = u'\u00AA' # "ª" self.fontDict_dev2["y"] = u'\u00A6' # "¦" self.fontDict_dev2["0"] = u'\u0030' # "0" self.fontDict_dev2["1"] = u'\u0031' # "1" self.fontDict_dev2["2"] = u'\u0032' # "2" self.fontDict_dev2["3"] = u'\u0033' # "3" self.fontDict_dev2["4"] = u'\u0034' # "4" self.fontDict_dev2["5"] = u'\u0035' # "5" self.fontDict_dev2["6"] = u'\u0036' # "6" self.fontDict_dev2["7"] = u'\u0037' # "7" self.fontDict_dev2["8"] = u'\u0038' # "8" self.fontDict_dev2["9"] = u'\u0039' # "9" self.fontDict_dev2["."] = u'\u002E' # "\" self.fontDict_dev2[","] = u'\u002C' # "," self.fontDict_dev2[":"] = u'\u003A' # ":" self.fontDict_dev2[";"] = u'\u003B' # ";" self.fontDict_dev2["?"] = u'\u003F' # "?" self.fontDict_dev2["*"] = u'\u002A' # "*" self.fontDict_dev2["^"] = u'\u00FB' # "û" self.fontDict_dev2["'"] = u'\u0027' # "'" self.fontDict_dev2['"'] = u'\u0022' # """ self.fontDict_dev2['%'] = u'\u0025' # "%" self.fontDict_dev2['$'] = u'\u00CB' + u'\u002E' # "Ë" self.fontDict_dev2['-'] = u'\u002D' # "-" self.fontDict_dev2['+'] = u'\u002B' # "+" self.fontDict_dev2['='] = u'\u003D' # "=" self.fontDict_dev2['@'] = u'\u0040' # "@" self.fontDict_dev2['`'] = u'\u0027' # "'" self.fontDict_dev2['#'] = u'\u0023' # "#" self.fontDict_dev2['&'] = u'\u0026' # "&" self.fontDict_dev2['('] = u'\u0028' # "(" self.fontDict_dev2[')'] = u'\u0029' # ")" self.fontDict_dev2['['] = u'\u005B' # "[" self.fontDict_dev2[']'] = u'\u005D' # "]" self.fontDict_dev2['{'] = u'\u007B' # "{" self.fontDict_dev2['}'] = u'\u007D' # "}" self.fontDict_dev2['<'] = u'\u003C' # "<" self.fontDict_dev2['>'] = u'\u003E' # ">" self.fontDict_dev2['/'] = u'\u002F' # "/" self.fontDict_dev2['\\'] = u'\u00FB' # "û" self.fontDict_dev2['|'] = u'\u005C' # "\" self.fontDict_dev2['!'] = u'\u0021' # "!" self.fontDict_dev2[' '] = u'\u0020' # " " self.fontDictDict["akrutidev2"] = self.fontDict_dev2 #init the unicode font self.fontDict_uni["a"] = u'\u0905' self.fontDict_uni["ai"] = u'\u0910' self.fontDict_uni["ai_maatraa"] = u'\u200D' + u'\u0948' self.fontDict_uni["b"] = u'\u092C' + u'\u094D' self.fontDict_uni["bh"] = u'\u092D' + u'\u094D' self.fontDict_uni["bhr"] = u'\u092D' + u'\u094D' + u'\u0930' self.fontDict_uni["ch"] = u'\u091A' + u'\u094D' self.fontDict_uni["chandra"] = u'\u0945' + u'\u094D' self.fontDict_uni["chandra_bindu"] = u'\u0901' + u'\u094D' self.fontDict_uni["chha"] = u'\u091B' + u'\u094D' self.fontDict_uni["d"] = u'\u0926' + u'\u094D' self.fontDict_uni["da"] = u'\u0926' self.fontDict_uni["deerghaviraam"] = u'\u0965' self.fontDict_uni["dh"] = u'\u0927' + u'\u094D' self.fontDict_uni["dnya"] = u'\u0950' self.fontDict_uni["D"] = u'\u0921' + u'\u094D' self.fontDict_uni["Da"] = u'\u0921' self.fontDict_uni["Dh"] = u'\u0922' + u'\u094D' self.fontDict_uni["Dha"] = u'\u0922' self.fontDict_uni["e"] = u'\u090F' self.fontDict_uni["e_maatraa"] = u'\u200D' + u'\u0947' self.fontDict_uni["ee"] = u'\u0908' self.fontDict_uni["ee_velaanti"] = u'\u200D' + u'\u0940' self.fontDict_uni["g"] = u'\u0917' + u'\u094D' self.fontDict_uni["gh"] = u'\u0918' + u'\u094D' self.fontDict_uni["gr"] = u'\u0917' + u'\u094D' + u'\u0930' self.fontDict_uni["gunile"] = u'\u00D7' self.fontDict_uni["h"] = u'\u0939' + u'\u094D' self.fontDict_uni["ha"] = u'\u0939' self.fontDict_uni["i"] = u'\u0907' self.fontDict_uni["i_velaanti"] = u'\u093F' + u'\u200D' self.fontDict_uni["j"] = u'\u091C' + u'\u094D' self.fontDict_uni["jh"] = u'\u091D' + u'\u094D' self.fontDict_uni["k"] = u'\u0915' + u'\u094D' self.fontDict_uni["ka"] = u'\u0915' self.fontDict_uni["kaanaa"] = u'\u200D' + u'\u093E' self.fontDict_uni["kaawaLaa"] = u'\u200D' + u'\u093E' self.fontDict_uni["kh"] = u'\u0916' + u'\u094D' self.fontDict_uni["kha"] = u'\u0916' self.fontDict_uni["ksh"] = u'\u0950' self.fontDict_uni["kr"] = u'\u0915' + u'\u0930' self.fontDict_uni["l"] = u'\u0932' + u'\u094D' self.fontDict_uni["L"] = u'\u0933' + u'\u094D' self.fontDict_uni["m"] = u'\u092E' + u'\u094D' self.fontDict_uni["n"] = u'\u0928' + u'\u094D' self.fontDict_uni["N"] = u'\u0923' + u'\u094D' self.fontDict_uni["om"] = u'\u0950' self.fontDict_uni["oo"] = u'\u090A' self.fontDict_uni["oo_maatraa"] = u'\u200D' + u'\u0942' self.fontDict_uni["paayamoDyaa"] = u'\u200D' + u'\u094D' self.fontDict_uni["p"] = u'\u092A' + u'\u094D' self.fontDict_uni["pa"] = u'\u092A' self.fontDict_uni["ph"] = u'\u092B' + u'\u094D' self.fontDict_uni["pha"] = u'\u092B' self.fontDict_uni["pra"] = u'\u092A' + u'\u094D' + u'\u0930' self.fontDict_uni["ra"] = u'\u0930' self.fontDict_uni["rafar"] = u'\u200D' + u'\u0945' self.fontDict_uni["rukar"] = u'\u200D' + u'\u0945' self.fontDict_uni["s"] = u'\u0938' + u'\u094D' self.fontDict_uni["sa"] = u'\u0938' self.fontDict_uni["sh"] = u'\u0936' + u'\u094D' self.fontDict_uni["shh"] = u'\u0937' + u'\u094D' self.fontDict_uni["shr"] = u'\u0936' + u'\u094D' + u'\u0930' self.fontDict_uni["t"] = u'\u0924' + u'\u094D' self.fontDict_uni["th"] = u'\u0925' + u'\u094D' self.fontDict_uni["tilda"] = u'\u007E' self.fontDict_uni["timba"] = u'\u0902' self.fontDict_uni["tr"] =u'\u0924' + u'\u094D' + u'\u0930' self.fontDict_uni["Ta"] = u'\u091F' + u'\u094D' self.fontDict_uni["Tha"] = u'\u0920' + u'\u094D' self.fontDict_uni["u"] = u'\u0909' self.fontDict_uni["u_maatraa"] = u'\u200D' + u'\u0941' self.fontDict_uni["v"] = u'\u0935' + u'\u094D' self.fontDict_uni["y"] = u'\u092F' + u'\u094D' self.fontDict_uni["0"] = u'\u0966' self.fontDict_uni["1"] = u'\u0967' self.fontDict_uni["2"] = u'\u0968' self.fontDict_uni["3"] = u'\u0969' self.fontDict_uni["4"] = u'\u096A' self.fontDict_uni["5"] = u'\u096B' self.fontDict_uni["6"] = u'\u096C' self.fontDict_uni["7"] = u'\u096D' self.fontDict_uni["8"] = u'\u096E' self.fontDict_uni["9"] = u'\u096F' self.fontDict_uni["."] = u'\u002E' self.fontDict_uni[","] = u'\u002C' self.fontDict_uni[":"] = u'\u003A' self.fontDict_uni[";"] = u'\u003B' self.fontDict_uni["?"] = u'\u003F' self.fontDict_uni["*"] = u'\u002A' self.fontDict_uni["^"] = u'\u005E' self.fontDict_uni["'"] = u'\u0027' self.fontDict_uni['"'] = u'\u0022' self.fontDict_uni['%'] = u'\u0025' self.fontDict_uni['$'] = u'\u0950' self.fontDict_uni['-'] = u'\u002D' self.fontDict_uni['+'] = u'\u002B' self.fontDict_uni['='] = u'\u003D' self.fontDict_uni['@'] = u'\u0040' self.fontDict_uni['`'] = u'\u0027' self.fontDict_uni['#'] = u'\u0023' self.fontDict_uni['&'] = u'\u0026' self.fontDict_uni['('] = u'\u0028' self.fontDict_uni[')'] = u'\u0029' self.fontDict_uni['['] = u'\u005B' self.fontDict_uni[']'] = u'\u005D' self.fontDict_uni['{'] = u'\u007B' self.fontDict_uni['}'] = u'\u007D' self.fontDict_uni['<'] = u'\u003C' self.fontDict_uni['>'] = u'\u003E' self.fontDict_uni['/'] = u'\u002F' self.fontDict_uni['\\'] = u'\u005C' self.fontDict_uni['|'] = u'\u0964' self.fontDict_uni['!'] = u'\u0021' self.fontDict_uni[' '] = u'\u0020' self.fontDictDict["Hindi_Gargi"] = self.fontDict_uni def getDict(self, fontID): return self.fontDictDict[fontID] class TransLit: def translateStr(self, text, fontDict): output = '' tmpstr = '' wordlist = string.split (text, ' ') for word in wordlist: index = 0 while index < len(word): #print "Translating char", word[index] + " ," + output, "index=", index tmpstr, charsTranslated = self.translateChar(word[index], index, word, fontDict) output += tmpstr index = index + 1 if charsTranslated > 1: index += charsTranslated - 1 #print tmpstr, "chars translated", charsTranslated output = output + ' ' return output def translateChar(self, char, index, word, fontDict): #print index, len(word), word output = '' charsTranslated = 1 if char in "Aa": if index == 0: output = output + fontDict["a"] else: output = output + fontDict["kaanaa"] elif char in "Bb": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["b"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["bh"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 elif index < len(word)-2 and word[index+2] in 'rR': if index < len(word)-3 and word[index+3] in 'aAeEiIoOuU': if word[index+3] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["bhr"] + fontDict["kaanaa"] if word[index+3] in "AaiI": charsTranslated = 4 else: charsTranslated = 3 else: output = output + fontDict["bhr"] charsTranslated = 3 else: output = output + fontDict["bh"] charsTranslated = 2 else: output = output + fontDict["b"] elif char in "Cc": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["ka"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["ch"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 elif index < len(word)-2 and word[index+2] in 'hH': if index < len(word)-3 and word[index+3] in 'aAeEiIoOuU': if word[index+3] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["chha"] if word[index+3] in "AaiI": charsTranslated = 4 else: charsTranslated = 3 else: output = output + fontDict["chha"] + fontDict["paayamoDyaa"] charsTranslated = 3 else: output = output + fontDict["ch"] charsTranslated = 2 else: output = output + fontDict["k"] elif char == "d": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["da"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["dh"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["dh"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'nN': if index < len(word)-2 and word[index+2] in 'yY': if index < len(word)-3 and word[index+3] in 'aAeEiIoOuU': if word[index+3] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["dnya"] if word[index+3] in "AaiI": charsTranslated = 4 else: charsTranslated = 3 else: output = output + fontDict["dnya"] + fontDict["paayamoDyaa"] charsTranslated = 3 else: output = output + fontDict["da"] + fontDict["paayamoDyaa"] + fontDict["n"] + fontDict["kaanaa"] + fontDict["paayamoDyaa"] charsTranslated = 2 else: output = output + fontDict["da"] + fontDict["paayamoDyaa"] elif char == "D": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["Da"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["Dha"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["Dha"] + fontDict["paayamoDyaa"] charsTranslated = 2 else: output = output + fontDict["Da"] + fontDict["paayamoDyaa"] elif char in "Ee": if index == 0: if index < len(word)-1 and word[index+1] in 'iI': output = output + fontDict["ai"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'Ee': output = output + fontDict["ee"] charsTranslated = 2 else: output = output + fontDict["e"] else: if index < len(word)-1 and word[index+1] in 'iI': output = output + fontDict["ai_maatraa"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'Ee': output = output + fontDict["ee_velaanti"] charsTranslated = 2 else: output = output + fontDict["e_maatraa"] elif char in "Ff": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["pha"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["ph"] elif char in "Gg": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["g"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["gh"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["gh"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'rR': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["gr"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["gr"] charsTranslated = 2 else: output = output + fontDict["g"] elif char in "Hh": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["ha"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["h"] elif char in "Ii": if index == 0: output = output + fontDict["i"] else: output = output + fontDict["i_velaanti"] elif char in "Jj": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["j"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["jh"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["jh"] charsTranslated = 2 else: output = output + fontDict["j"] elif char in "Kk": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["ka"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["kha"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["kh"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'sS': if index < len(word)-2 and word[index+2] in 'hH': if index < len(word)-3 and word[index+3] in 'aAeEiIoOuU': output = output + fontDict["ksh"] + fontDict["kaanaa"] if word[index+3] in "Aa": charsTranslated = 4 else: charsTranslated = 3 else: output = output + fontDict["ksh"] charsTranslated = 3 else: output = output + fontDict["k"] + fontDict["s"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'rR': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["kr"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["kr"] charsTranslated = 2 else: output = output + fontDict["k"] elif char == "l": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["l"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["l"] elif char == "L": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["L"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["L"] + fontDict["paayamoDyaa"] elif char in "Mm": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["m"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] not in 'aAeEiIoOuU': output = output + fontDict["m"] else: output = output + fontDict["m"] + fontDict["kaanaa"] + fontDict["paayamoDyaa"] elif char in "n": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["n"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] not in 'aAeEiIoOuU': output = output + fontDict["n"] else: output = output + fontDict["n"] + fontDict["kaanaa"] + fontDict["paayamoDyaa"] elif char in "N": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["N"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["N"] elif char in "Oo": if index == 0: if index < len(word)-1 and word[index+1] in 'oO': output = output + fontDict["oo"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'uU': output = output + fontDict["a"] + fontDict["kaanaa"] + fontDict["ai_maatraa"] charsTranslated = 2 else: output = output + fontDict["a"] + fontDict["kaanaa"] + fontDict["e_maatraa"] else: if index < len(word)-1 and word[index+1] in 'oO': output = output + fontDict["oo_maatraa"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'uU': output = output + fontDict["kaanaa"] + fontDict["ai_maatraa"] charsTranslated = 2 else: output = output + fontDict["kaanaa"] + fontDict["e_maatraa"] elif char in "Pp": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["pa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["pha"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["ph"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'rR': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["pra"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["pra"] + fontDict["paayamoDyaa"] charsTranslated = 2 else: output = output + fontDict["p"] elif char in "Rr": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["ra"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["ra"] + fontDict["paayamoDyaa"] elif char in "Ss": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["s"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["sh"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 elif index < len(word)-2 and word[index+2] in 'hH': if index < len(word)-3 and word[index+3] in 'aAeEiIoOuU': if word[index+3] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["shh"] + fontDict["kaanaa"] if word[index+3] in "AaiI": charsTranslated = 4 else: charsTranslated = 3 else: output = output + fontDict["shh"] charsTranslated = 3 elif index < len(word)-2 and word[index+2] in 'rR': if index < len(word)-3 and word[index+3] in 'aAeEiIoOuU': if word[index+3] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["shr"] + fontDict["kaanaa"] if word[index+3] in "AaiI": charsTranslated = 4 else: charsTranslated = 3 else: output = output + fontDict["shr"] charsTranslated = 3 else: output = output + fontDict["sh"] charsTranslated = 2 else: output = output + fontDict["s"] elif char == "t": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["t"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["th"] + fontDict["kaanaa"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["th"] charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'rR': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["tr"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["tr"] + fontDict["paayamoDyaa"] charsTranslated = 2 else: output = output + fontDict["t"] elif char == "T": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["Ta"] if word[index+1] in "AaiI": charsTranslated = 2 elif index < len(word)-1 and word[index+1] in 'hH': if index < len(word)-2 and word[index+2] in 'aAeEiIoOuU': if word[index+2] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["Tha"] if word[index+2] in "AaiI": charsTranslated = 3 else: charsTranslated = 2 else: output = output + fontDict["Tha"] + fontDict["paayamoDyaa"] charsTranslated = 2 else: output = output + fontDict["Ta"] + fontDict["paayamoDyaa"] elif char in "Uu": if index == 0: if index < len(word)-1 and word[index+1] in 'uU': output = output + fontDict["oo"] charsTranslated = 2 else: output = output + fontDict["u"] else: if index < len(word)-1 and word[index+1] in 'uU': output = output + fontDict["oo_maatraa"] charsTranslated = 2 else: output = output + fontDict["u_maatraa"] elif char in "VvwW": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["v"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["v"] elif char in "Xx": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["ksh"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["ksh"] elif char in "Yy": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["y"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["y"] elif char in "Zz": if index < len(word)-1 and word[index+1] in 'aAeEiIoOuU': if word[index+1] in "Ii": output = output + fontDict["i_velaanti"] output = output + fontDict["jh"] + fontDict["kaanaa"] if word[index+1] in "AaiI": charsTranslated = 2 else: output = output + fontDict["jh"] elif char == "0": output = output + fontDict["0"] elif char == "1": output = output + fontDict["1"] elif char == "2": output = output + fontDict["2"] elif char == "3": output = output + fontDict["3"] elif char == "4": output = output + fontDict["4"] elif char == "5": output = output + fontDict["5"] elif char == "6": output = output + fontDict["6"] elif char == "7": output = output + fontDict["7"] elif char == "8": output = output + fontDict["8"] elif char == "9": output = output + fontDict["9"] elif char == ".": if index < len(word)-1 and word[index+1] in 'hmnorRx|MNcuU': if word[index+1] in "h": output = output + fontDict[":"] charsTranslated = 2 elif word[index+1] in "mn": output = output + fontDict["timba"] charsTranslated = 2 elif word[index+1] in "MN": output = output + fontDict["chandra_bindu"] charsTranslated = 2 elif word[index+1] in "r": output = output + fontDict["rafar"] charsTranslated = 2 elif word[index+1] in "R": output = output + fontDict["kaawaLaa"] charsTranslated = 2 elif word[index+1] in "uU": output = output + fontDict["rukar"] charsTranslated = 2 elif word[index+1] in "x": output = output + fontDict["gunile"] charsTranslated = 2 elif word[index+1] in "|": output = output + fontDict["deerghaviraam"] charsTranslated = 2 elif word[index+1] in "c": output = output + fontDict["chandra"] charsTranslated = 2 elif word[index+1] in "o": if index < len(word)-2 and word[index+2] in "m": output = output + fontDict["om"] charsTranslated = 3 else: output = output + fontDict["."] else: output = output + fontDict["."] else: output = output + fontDict["."] elif char == ",": output = output + fontDict[","] elif char == ":": output = output + fontDict[":"] elif char == ";": output = output + fontDict[";"] elif char == "?": output = output + fontDict["?"] elif char == "*": output = output + fontDict["*"] elif char == "^": output = output + fontDict["^"] elif char == "'": output = output + fontDict["'"] elif char == '"': output = output + fontDict['"'] elif char == '%': output = output + fontDict['%'] elif char == '$': output = output + fontDict['$'] elif char == '-': output = output + fontDict['-'] elif char == '+': output = output + fontDict['+'] elif char == '=': output = output + fontDict['='] elif char in "@": output = output + fontDict['@'] elif char in "~": output = output + fontDict["tilda"] elif char in "`": output = output + fontDict["`"] elif char in "#": output = output + fontDict["#"] elif char in "&": output = output + fontDict["&"] elif char in "(": output = output + fontDict["("] elif char in ")": output = output + fontDict[")"] elif char in "[": output = output + fontDict["["] elif char in "]": output = output + fontDict["]"] elif char in "{": output = output + fontDict["{"] elif char in "}": output = output + fontDict["}"] elif char in "<": output = output + fontDict["<"] elif char in ">": output = output + fontDict[">"] elif char in "/": output = output + fontDict["/"] elif char in "\\": output = output + fontDict["\\"] elif char in "|": output = output + fontDict["|"] elif char in "!": output = output + fontDict["!"] elif char in " ": output = output + fontDict[" "] elif char in "\n": output = output + "\n" elif char in "\r": output = output + "\r" else: output = output + fontDict["om"] return output, charsTranslated class App: def __init__(self, master): self.werd_version = "1.2" self.werd_copyright = "WERD v 1.2 (C) 2007-2009, Atul Nene (www.atulnene.com)" self.master = master self.statusText = StringVar() self.mTextStr = StringVar() self.editorFontSize = StringVar() self.editorFontSize.set("L") # default value self.marathiFontName = "Shivaji01" self.marathiLabelFontSize = 15 self.marathiEditFontSize = 20 self.determineEditorFontSize() self.fontDict = FontDict().getDict("Shivaji01") self.tr = TransLit() self.currentWord = "" self.samples = [".| shree gaNeshaaya nama.h .|","a aa i ee e ei o ou am a.h", "ka kaa ki kee ku koo ke kei ka.c ko kou ka.m ka.M ka.h", "$ ~ om .om", "namaskaara, namashkaara", "aapa keise ho ? saba kushala ma.ngala to hei ?", "deepaka to mu.nshee premachandajee kaa fa.cna hei", "(98 + 5 - 3) .x 2 = 200", "kaamaata aahesa kaa ?", "maazyaashee bola naa, cha.cTa ? eemela ?", "pu. la. vaachala.nsa ? aaNee kusumaagraja ?", "yaa janmaawara yaa jagaNyaawara shatadaa prema karaave", "bhaarateeya sabhyataa bahuta praacheena hei", "paga ghu.ngaroo baa.ndha meeraa naachee thee", "pleeja mujhe kala sTeshana para Draa.c.Rpa karanaa, naa bhoolanaa", "1 Daalara kareeba $ 43 ke baraabara hei", "bhaarata maazee maata.ubhoomee aahe", "chhatrapatee shivaajee maharaajaa.nchaa vijaya aso", "mu.ngyaa.nnee merupava.rta tara giLalaa naahee naa ?", "o paavana.n, mhora.n bagaa kee", "o yaara, munne ko paraa.nThe khilaa", "are o saambhaa ! kitane aadamee the ?", "devanaagaree me sabhee bhaashhaa e.n vyakta ho sakatee hei.n", "ruda.RveeNaa me jyaadaatara kha.rja ke swara bajate hei.n", "chha dnyaa Thi khee kshe bhei Dho thou ha.m la.h", "( ) [ ] { } < > ", " - + .x = / \ | ! .|", "kata.r.utvavaana chaa.Ndabeebeelaa khaa.cfa navhataa" ] self.currSampleId = 0 self.frame = Frame (master) master.title(self.werd_copyright) self.frame.grid() self.infoFrame = Frame (self.frame, bd=1, relief=SUNKEN) self.infoFrame.grid(row=0,column=0,sticky=NSEW) self.label0 = Label (self.infoFrame, wraplength=150, text = "Write in English, Read in Devanagari with \nWERD, \nthe phonetic transliterator.\n", font=("Helvetica", 10, "bold")) self.label0.grid (row=0) self.label1 = Label (self.infoFrame, wraplength=150, text = self.tr.translateStr ("a.ngrejee likho, devanaagaree paDho",self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.label1.grid (row=1) self.label2 = Label (self.infoFrame, wraplength=150, text = self.tr.translateStr ("i.ngrajee lihaa, devanaagaree vaachaa",self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.label2.grid (row=2) self.label3 = Label (self.infoFrame, wraplength=150, text = "WERD comes with ABSOLUTELY NO WARRANTY; \n This is free software, and you are welcome to \nredistribute it under certain conditions; see \nhttp://www.gnu.org/licenses/gpl.html for details.\n") self.label3.grid(row=3) self.label4 = Label (self.infoFrame, wraplength=150, text = "Please write to atul@atulnene.com with \ncomments and suggestions.\n\nPlease see http://www.atulnene.com/werd.html for help.\n") self.label4.grid(row=4) self.workPanel = Frame (self.frame, bd=1, relief=SUNKEN) self.workPanel.grid(row=0, column=1, sticky=NSEW) self.tabPanel = Frame (self.workPanel) self.tabPanel.pack(fill=BOTH) self.fontLabel = Label(self.tabPanel, text="Font :", anchor=CENTER) self.fontLabel.grid(row=0, column=0, rowspan=2) self.fonts = ["Shivaji01", "Shivaji02", "Shivaji05", "xdvng", "akrutidev2", "Hindi_Gargi"] self.varFont = IntVar() self.varFont.set(1) tmpRadio = Radiobutton (self.tabPanel, text=self.fonts[0], variable=self.varFont, value=1, command=self.cmdShivaji01) tmpRadio.grid(row=0, column=1) tmpRadio = Radiobutton (self.tabPanel, text=self.fonts[1], variable=self.varFont, value=2, command=self.cmdShivaji02) tmpRadio.grid(row=0, column=2) tmpRadio = Radiobutton (self.tabPanel, text=self.fonts[2], variable=self.varFont, value=3, command=self.cmdShivaji05) tmpRadio.grid(row=0, column=3) tmpRadio = Radiobutton (self.tabPanel, text=self.fonts[3], variable=self.varFont, value=4, command=self.cmdxdvng) tmpRadio.grid(row=1, column=1) tmpRadio = Radiobutton (self.tabPanel, text=self.fonts[4], variable=self.varFont, value=5, command=self.cmdAkrutiDev2) tmpRadio.grid(row=1, column=2) tmpRadio = Radiobutton (self.tabPanel, text="Unicode (Gargi)", variable=self.varFont, value=6, command=self.cmdGargi) tmpRadio.grid(row=1, column=3) self.editorFontSizeLabel = Label(self.tabPanel, text="Size :", anchor=CENTER) #self.editorFontSizeLabel.pack(side=LEFT) self.editorFontSizeLabel.grid(row=0, column=4, columnspan=2) editorFontSizes = ["S", "M", "L", "XL", "XXL"] tmpColumn = 6 for size in editorFontSizes: tmpRadio = Radiobutton (self.tabPanel, text=size, variable=self.editorFontSize, value=size, command=self.cmdEditorFontSize, indicatoron=0) #tmpRadio.pack(side=LEFT) tmpRadio.grid(row=0, column=tmpColumn) tmpColumn = tmpColumn + 1 self.editorPanel = Frame (self.workPanel) self.editorPanel.pack(fill=BOTH, expand=1) self.eNotePanel = Frame (self.editorPanel) self.eNotePanel.pack(fill=BOTH, expand=1) self.eNoteScrollbar = Scrollbar (self.eNotePanel) self.eNoteScrollbar.pack(side=RIGHT, fill=Y) self.eNote = Text (self.eNotePanel, height=5, width=30, yscrollcommand=self.eNoteScrollbar.set) self.eNote.pack(side=LEFT, fill=BOTH, expand=1) self.eNote.bind('', self.reportEvent) self.eNoteScrollbar.config(command=self.eNote.yview) self.buttonPanel = Frame (self.editorPanel) self.buttonPanel.pack(fill=BOTH) self.preview = Label (self.buttonPanel, height=1, width=15, bd=1, relief=SUNKEN, anchor=W, justify=LEFT, font=(self.marathiFontName, self.marathiEditFontSize)) self.preview.pack(side=LEFT) self.trans = Button (self.buttonPanel, text="Transliterate Now", command=self.transliterate) self.trans.pack(side=LEFT) self.copyTo = Button (self.buttonPanel, text="Copy To Clipboard (Select+^C))", command=self.copyToClipboard) self.copyTo.pack(side=LEFT) self.appendTo = Button (self.buttonPanel, text="Add To Clipboard", command=self.appendToClipboard) self.appendTo.pack(side=LEFT) self.mNotePanel = Frame (self.editorPanel) self.mNotePanel.pack(fill=BOTH, expand=1) self.mNoteScrollbar = Scrollbar (self.mNotePanel) self.mNoteScrollbar.pack(side=RIGHT, fill=Y) self.mNote = Text (self.mNotePanel, height=5, width=20, font=(self.marathiFontName, self.marathiEditFontSize), yscrollcommand=self.mNoteScrollbar.set) self.mNote.pack(side=LEFT, fill=BOTH, expand=1) self.mNoteScrollbar.config(command=self.mNote.yview) self.examplePanel = Frame (self.workPanel) self.examplePanel.pack(side=LEFT) self.exMore = Button (self.examplePanel, text="More Examples >>", command=self.moreExamples) self.exMore.grid (row=5, column=0, sticky=W) self.exLabel10 = Label (self.examplePanel, wraplength=200, text=self.samples[0], font=("Helvetica", 10, "bold")) self.exLabel10.grid (row=1, column=0, stick=W) self.exLabel11 = Label (self.examplePanel, wraplength=300, text = self.tr.translateStr (self.samples[0],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel11.grid (row=1, column=1, sticky=W) self.exLabel20 = Label (self.examplePanel, wraplength=200, text=self.samples[1], font=("Helvetica", 10, "bold")) self.exLabel20.grid (row=2, column=0, sticky=W) self.exLabel21 = Label (self.examplePanel, wraplength=300, text = self.tr.translateStr (self.samples[1],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel21.grid (row=2, column=1, sticky=W) self.exLabel30 = Label (self.examplePanel, wraplength=200, text=self.samples[2], font=("Helvetica", 10, "bold")) self.exLabel30.grid (row=3, column=0, sticky=W) self.exLabel31 = Label (self.examplePanel, wraplength=300, text = self.tr.translateStr (self.samples[2],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel31.grid (row=3, column=1, sticky=W) self.exLabel40 = Label (self.examplePanel, wraplength=200, text=self.samples[3], font=("Helvetica", 10, "bold")) self.exLabel40.grid (row=4, column=0, sticky=W) self.exLabel41 = Label (self.examplePanel, wraplength=300, text = self.tr.translateStr (self.samples[3],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel41.grid (row=4, column=1, sticky=W) self.help = Label(self.frame, text='Ensure you have installed one of the above fonts. Use WERD with your favorite application this way : \n1. Set the correct font in that application (eg. your chat application, or your html email editor)\n2. Simply select and copy the devanagari content above and paste into it.\nIts that easy ! Be sure to tell your friends too ...\nNote: Characters not supported by chosen font are displayed as "om"', bd=1, relief=SUNKEN, anchor=W, justify=LEFT) self.help.grid(row=1,column=0,columnspan=2,sticky=NSEW) def determineEditorFontSize(self): if self.marathiFontName == "xdvng": if self.editorFontSize.get() == "S": self.marathiEditFontSize = 7 elif self.editorFontSize.get() == "M": self.marathiEditFontSize = 11 elif self.editorFontSize.get() == "L": self.marathiEditFontSize = 15 elif self.editorFontSize.get() == "XL": self.marathiEditFontSize = 19 elif self.editorFontSize.get() == "XXL": self.marathiEditFontSize = 21 else: if self.editorFontSize.get() == "S": self.marathiEditFontSize = 12 elif self.editorFontSize.get() == "M": self.marathiEditFontSize = 16 elif self.editorFontSize.get() == "L": self.marathiEditFontSize = 20 elif self.editorFontSize.get() == "XL": self.marathiEditFontSize = 24 elif self.editorFontSize.get() == "XXL": self.marathiEditFontSize = 28 def cmdEditorFontSize(self): oldMarathiEditFontSize = self.marathiEditFontSize self.determineEditorFontSize() if oldMarathiEditFontSize != self.marathiEditFontSize: self.mNote.config(font=(self.marathiFontName, self.marathiEditFontSize)) self.preview.config(font=(self.marathiFontName, self.marathiEditFontSize)) def cmdGargi(self): self.marathiFontName = "Hindi_Gargi" self.marathiLabelFontSize = 15 self.determineEditorFontSize() self.affectFontChange() def cmdAkrutiDev2(self): self.marathiFontName = "akrutidev2" self.marathiLabelFontSize = 15 self.determineEditorFontSize() self.affectFontChange() def cmdxdvng(self): self.marathiFontName = "xdvng" self.marathiLabelFontSize = 10 self.determineEditorFontSize() self.affectFontChange() def cmdShivaji01(self): self.marathiFontName = "Shivaji01" self.marathiLabelFontSize = 15 self.determineEditorFontSize() self.affectFontChange() def cmdShivaji02(self): self.marathiFontName = "Shivaji02" self.marathiLabelFontSize = 15 self.determineEditorFontSize() self.affectFontChange() def cmdShivaji05(self): self.marathiFontName = "Shivaji05" self.marathiLabelFontSize = 15 self.determineEditorFontSize() self.affectFontChange() def affectFontChange(self): self.fontDict = FontDict().getDict(self.marathiFontName) self.label1.config(font=(self.marathiFontName, self.marathiLabelFontSize, "bold"),text = self.tr.translateStr ("angrejee likho, devanaagaree paDho",self.fontDict)) self.label2.config(font=(self.marathiFontName, self.marathiLabelFontSize, "bold"),text = self.tr.translateStr ("ingrajee lihaa, devanaagaree vaachaa",self.fontDict)) self.preview.config(font=(self.marathiFontName, self.marathiEditFontSize)) self.mNote.config(font=(self.marathiFontName, self.marathiEditFontSize)) self.exLabel11.config(font=(self.marathiFontName, self.marathiLabelFontSize, "bold"),text = self.tr.translateStr (self.samples[self.currSampleId], self.fontDict)) self.exLabel21.config(font=(self.marathiFontName, self.marathiLabelFontSize, "bold"),text = self.tr.translateStr (self.samples[self.currSampleId+1], self.fontDict)) self.exLabel31.config(font=(self.marathiFontName, self.marathiLabelFontSize, "bold"),text = self.tr.translateStr (self.samples[self.currSampleId+2], self.fontDict)) self.exLabel41.config(font=(self.marathiFontName, self.marathiLabelFontSize, "bold"),text = self.tr.translateStr (self.samples[self.currSampleId+3], self.fontDict)) self.transliterate() def reportEvent(self, event): #self.eNote.insert(END,event.keysym) #print event.keysym #print event.char #print event.keycode #print event.num #print event.type if event.keysym == "space": self.transliterate() self.currentWord = "" self.preview.config(text="") #self.preview.delete (1.0,END) elif event.keysym == "BackSpace": if len(self.currentWord) >= 1: self.currentWord = self.currentWord.rstrip(self.currentWord[len(self.currentWord)-1]) self.preview.config(text=self.tr.translateStr(self.currentWord, self.fontDict)) else: self.currentWord = self.currentWord + event.char self.preview.config(text=self.tr.translateStr(self.currentWord, self.fontDict)) def transliterate(self): self.mNote.delete (1.0,END) self.mNote.insert (END, self.tr.translateStr(self.eNote.get(1.0, END), self.fontDict)) def copyToClipboard(self): root.clipboard_clear() root.clipboard_append(self.mNote.get(1.0,END)) def appendToClipboard(self): root.clipboard_append(self.mNote.get(1.0,END)) def moreExamples(self): if (self.currSampleId + 4) == len(self.samples): self.currSampleId = 0 elif (self.currSampleId + 4) > len(self.samples): self.currSampleId = len(self.samples) - 4 else: self.currSampleId = self.currSampleId + 4 if (self.currSampleId + 4) > len(self.samples): self.currSampleId = len(self.samples) - 4 self.exLabel10.config(text=self.samples[self.currSampleId]) self.exLabel11.config(text = self.tr.translateStr (self.samples[self.currSampleId],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel20.config(text=self.samples[self.currSampleId+1]) self.exLabel21.config(text = self.tr.translateStr (self.samples[self.currSampleId+1],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel30.config(text=self.samples[self.currSampleId+2]) self.exLabel31.config(text = self.tr.translateStr (self.samples[self.currSampleId+2],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) self.exLabel40.config(text=self.samples[self.currSampleId+3]) self.exLabel41.config(text = self.tr.translateStr (self.samples[self.currSampleId+3],self.fontDict), font=(self.marathiFontName, self.marathiLabelFontSize, "bold")) def doQuit(self): self.master.quit() def doHelp(self): #TODO: dont know how to do this yet in a platform independent way #import os #os.popen("start http://www.atulnene.com/") pass root = Tk() app = App(root) root.mainloop () print"Thanks for using WERD. Bye"