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