r4499: Escape " characters when generating translations for the Options.xml file
[rox-filer/ma.git] / ROX-Filer / src / po / tips.py
blob3a1b227a8b1adf140384f56ef1274da3a7b1e5f1
1 # Grab the tips from Options.xml
3 from xml.sax import *
4 from xml.sax.handler import ContentHandler
5 import string, os
7 print "Extracting translatable bits from Options.xml..."
9 class Handler(ContentHandler):
10 data = ""
12 def startElement(self, tag, attrs):
13 for x in ['title', 'label', 'end', 'unit']:
14 if attrs.has_key(x):
15 self.trans(attrs[x])
16 self.data = ""
18 def characters(self, data):
19 self.data = self.data + data
21 def endElement(self, tag):
22 data = string.strip(self.data)
23 if data:
24 self.trans(data)
25 self.data = ""
27 def trans(self, data):
28 data = string.join(string.split(data, '\n'), '\\n')
29 if data:
30 out.write('_("%s")\n' % data.replace('"', '\\"'))
32 try:
33 os.chdir("po")
34 except OSError:
35 pass
37 out = open('../tips', 'wb')
38 parse('../../Options.xml', Handler())
39 out.close()