add some translations (translations in the wizard don't work in some places)
[enigma2.git] / po / xml2po.py
1 #!/usr/bin/python
2 import sys
3 import os
4 from xml.sax import make_parser
5 from xml.sax.handler import ContentHandler
6
7 class parseXML(ContentHandler):
8         def __init__(self, attrlist):
9                 self.isPointsElement, self.isReboundsElement = 0, 0
10                 self.attrlist = attrlist
11
12         def startElement(self, name, attrs):
13                 if (attrs.has_key('text')):
14                         attrlist[attrs.get('text', "")] = "foo"
15                 if (attrs.has_key('title')):
16                         attrlist[attrs.get('title', "")] = "foo"
17                 if (attrs.has_key('value')):
18                         attrlist[attrs.get('value', "")] = "foo"
19                 if (attrs.has_key('caption')):
20                         attrlist[attrs.get('caption', "")] = "foo"
21
22 parser = make_parser()
23
24 attrlist = {}           
25
26 contentHandler = parseXML(attrlist)
27 parser.setContentHandler(contentHandler)
28
29 dir = os.listdir(sys.argv[1])
30 for x in dir:
31         if (str(x[-4:]) == ".xml"):
32                 parser.parse(sys.argv[1] + str(x))
33
34 #parser.parse(sys.argv[1])
35
36 for k, v in attrlist.items():
37         print
38         print '#: ' + sys.argv[1]
39         print 'msgid "' + str(k) + '"'
40         print 'msgstr ""'
41