2009-08-29 21:28:46 -04:00
|
|
|
import xml.dom.minidom
|
|
|
|
import sys
|
|
|
|
|
|
|
|
f = open('./data/po/gui_strings.h', 'w')
|
|
|
|
|
2010-02-15 19:33:41 -05:00
|
|
|
def traverse(file, node, isChallenge, isGP, level=0):
|
2009-08-29 21:28:46 -04:00
|
|
|
|
|
|
|
for e in node.childNodes:
|
|
|
|
if e.localName == None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
#print ' '*level, e.localName
|
|
|
|
|
|
|
|
comment = None
|
|
|
|
if e.hasAttribute("I18N"):
|
|
|
|
comment = e.getAttribute("I18N")
|
2009-12-22 16:57:15 -05:00
|
|
|
|
2010-02-15 19:33:41 -05:00
|
|
|
if isChallenge or isGP:
|
2009-12-22 16:57:15 -05:00
|
|
|
if e.hasAttribute("name"):
|
|
|
|
# print "Label=", e.getAttribute("name"), " Comment=", comment
|
|
|
|
line = ""
|
|
|
|
if comment == None:
|
2010-01-07 18:22:45 -05:00
|
|
|
line += "//I18N: " + file + "\n_(\"" + e.getAttribute("name") + "\")\n\n"
|
2009-12-22 16:57:15 -05:00
|
|
|
else:
|
2010-01-07 18:22:45 -05:00
|
|
|
line += "//I18N: File : " + file + "\n//I18N: " + comment + "\n_(\"" + e.getAttribute("name") + "\");\n\n"
|
2009-12-22 16:57:15 -05:00
|
|
|
|
|
|
|
f.write( line )
|
|
|
|
|
|
|
|
if e.hasAttribute("description"):
|
|
|
|
# print "Label=", e.getAttribute("description"), " Comment=", comment
|
|
|
|
line = ""
|
|
|
|
if comment == None:
|
2010-01-07 18:22:45 -05:00
|
|
|
line += "//I18N: " + file + "\n_(\"" + e.getAttribute("description") + "\")\n\n"
|
2009-12-22 16:57:15 -05:00
|
|
|
else:
|
2010-01-07 18:22:45 -05:00
|
|
|
line += "//I18N: File : " + file + "\n//I18N: " + comment + "\n_(\"" + e.getAttribute("description") + "\");\n\n"
|
2009-12-22 16:57:15 -05:00
|
|
|
|
|
|
|
f.write( line )
|
|
|
|
else:
|
|
|
|
if e.hasAttribute("text"):
|
|
|
|
# print "Label=", e.getAttribute("text"), " Comment=", comment
|
|
|
|
line = ""
|
|
|
|
if comment == None:
|
2010-01-07 18:22:45 -05:00
|
|
|
line += "//I18N: " + file + "\n_(\"" + e.getAttribute("text") + "\")\n\n"
|
2009-12-22 16:57:15 -05:00
|
|
|
else:
|
2010-01-07 18:22:45 -05:00
|
|
|
line += "//I18N: " + file + "\n//I18N: " + comment + "\n_(\"" + e.getAttribute("text") + "\");\n\n"
|
2009-12-22 16:57:15 -05:00
|
|
|
|
|
|
|
f.write( line )
|
2009-08-29 21:28:46 -04:00
|
|
|
|
|
|
|
|
2010-02-15 19:33:41 -05:00
|
|
|
traverse(file, e, isChallenge, isGP, level+1)
|
2009-08-29 21:28:46 -04:00
|
|
|
|
|
|
|
filenames = sys.argv[1:]
|
|
|
|
for file in filenames:
|
2010-02-15 19:33:41 -05:00
|
|
|
#print "Parsing", file
|
2009-12-22 16:57:15 -05:00
|
|
|
|
|
|
|
isChallenge = False
|
2010-02-15 19:33:41 -05:00
|
|
|
isGP = False
|
|
|
|
|
2009-12-22 16:57:15 -05:00
|
|
|
if file.endswith(".challenge"):
|
|
|
|
isChallenge = True
|
2010-02-15 19:33:41 -05:00
|
|
|
if file.endswith(".grandprix"):
|
|
|
|
isGP = True
|
2009-12-22 16:57:15 -05:00
|
|
|
|
2010-02-15 19:33:41 -05:00
|
|
|
try:
|
|
|
|
doc = xml.dom.minidom.parse(file)
|
|
|
|
except:
|
|
|
|
print "============================================"
|
|
|
|
print "/!\\ Expat doesn't like ", file, "!"
|
|
|
|
print "============================================"
|
|
|
|
|
|
|
|
traverse(file, doc, isChallenge, isGP)
|
2009-08-29 21:28:46 -04:00
|
|
|
|