# -*- coding: utf-8 *-
#!/usr/bin/env python
languages = {
'AFRIKAANS' : "af",
'ALBANIAN' : "sq",
'AMHARIC' : "am",
'ARABIC' : "ar",
'ARMENIAN' : "hy",
'AZERBAIJANI' : "az",
'BASQUE' : "eu",
'BELARUSIAN' : "be",
'BENGALI' : "bn",
'BIHARI' : "bh",
'BULGARIAN' : "bg",
'BURMESE' : "my",
'CATALAN' : "ca",
'CHEROKEE' : "chr",
'CHINESE' : "zh",
'CHINESE_SIMPLIFIED' : "zh-CN",
'CHINESE_TRADITIONAL' : "zh-TW",
'CROATIAN' : "hr",
'CZECH' : "cs",
'DANISH' : "da",
'DHIVEHI' : "dv",
'DUTCH' : "nl",
'ENGLISH' : "en",
'ESPERANTO' : "eo",
'ESTONIAN' : "et",
'FILIPINO' : "tl",
'FINNISH' : "fi",
'FRENCH' : "fr",
'GALICIAN' : "gl",
'GEORGIAN' : "ka",
'GERMAN' : "de",
'GREEK' : "el",
'GUARANI' : "gn",
'GUJARATI' : "g",
'HEBREW' : "iw",
'HINDI' : "hi",
'HUNGARIAN' : "hu",
'ICELANDIC' : "is",
'INDONESIAN' : "id",
'INUKTITUT' : "iu",
'ITALIAN' : "it",
'JAPANESE' : "ja",
'KANNADA' : "kn",
'KAZAKH' : "kk",
'KHMER' : "km",
'KOREAN' : "ko",
'KURDISH': "ku",
'KYRGYZ': "ky",
'LAOTHIAN': "lo",
'LATVIAN' : "lv",
'LITHUANIAN' : "lt",
'MACEDONIAN' : "mk",
'MALAY' : "ms",
'MALAYALAM' : "ml",
'MALTESE' : "mt",
'MARATHI' : "mr",
'MONGOLIAN' : "mn",
'NEPALI' : "ne",
'NORWEGIAN' : "no",
'ORIYA' : "or",
'PASHTO' : "ps",
'PERSIAN' : "fa",
'POLISH' : "pl",
'PORTUGUESE' : "pt",
'PUNJABI' : "pa",
'ROMANIAN' : "ro",
'RUSSIAN' : "ru",
'SANSKRIT' : "sa",
'SERBIAN' : "sr",
'SINDHI' : "sd",
'SINHALESE' : "si",
'SLOVAK' : "sk",
'SLOVENIAN' : "sl",
'SPANISH' : "es",
'SWAHILI' : "sw",
'SWEDISH' : "sv",
'TAJIK' : "tg",
'TAMIL' : "ta",
'TAGALOG' : "tl",
'TELUGU' : "te",
'THAI' : "th",
'TIBETAN' : "bo",
'TURKISH' : "tr",
'UKRAINIAN' : "uk",
'URDU' : "ur",
'UZBEK' : "uz",
'UIGHUR' : "ug",
'VIETNAMESE' : "vi",
}
class Entry:
def __init__(self):
self.keyword = ''
self.module = ''
self.id = 0
self.listText = []
self.listFileName = []
self.messageFile = ''
def __str__(self):
listtxt = ''
for tx in self.listText:
listtxt = listtxt + tx.getXMLValue()
return "Entry(id='%s',keyword='%s',module='%s',listText='%s')"%(
self.id, self.keyword, self.module, listtxt)
def entry2xml(self):
toAdd = ''
for tex in self.listText:
val = 'Problem'
try:
toAdd = toAdd + tex.getXMLValue() + '\n'
except:
toAdd = toAdd + ' ' + 'Problem' + '\n'
#res = ' \n'
res = ' \n'
res = res + ' ' + self.keyword + '\n'
res = res + ' ' + self.module + '\n'
res = res + toAdd
res = res + ' \n'
return res
def createMessgaeFromKeyword(self):
return '#{messages[\'' + self.keyword + '\']}'
class Text:
def __init__(self):
self.value = ''
self.lang = ''
def __str__(self):
return "Text(lang='%s', value='%s')"%(
self.lang, self.value.encode('utf-8'))
def getXMLValue(self):
return " %s"%(
languages[self.lang], self.value.encode('utf-8')
)