[GRASS-SVN] r34788 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 8 01:36:10 EST 2008


Author: glynn
Date: 2008-12-08 01:36:09 -0500 (Mon, 08 Dec 2008)
New Revision: 34788

Modified:
   grass/trunk/gui/wxpython/
   grass/trunk/gui/wxpython/Makefile
   grass/trunk/gui/wxpython/gui_modules/menudata.py
Log:
Generate dummy Python file containing menu strings for translation



Property changes on: grass/trunk/gui/wxpython
___________________________________________________________________
Name: svn:ignore
   + menustrings.py


Modified: grass/trunk/gui/wxpython/Makefile
===================================================================
--- grass/trunk/gui/wxpython/Makefile	2008-12-07 19:41:20 UTC (rev 34787)
+++ grass/trunk/gui/wxpython/Makefile	2008-12-08 06:36:09 UTC (rev 34788)
@@ -17,6 +17,7 @@
 	if [ ! -d $(ETCDIR)/$$dir ] ; then $(MKDIR) $(ETCDIR)/$$dir ; fi ; \
 	done
 	$(MAKE) $(DSTFILES)
+	$(MAKE) menustrings.py
 
 $(ETCDIR)/scripts/wxgui: wxgui
 	$(INSTALL) $< $@
@@ -27,3 +28,5 @@
 $(ETCDIR)/%: %
 	$(INSTALL_DATA) $< $@
 
+menustrings.py: gui_modules/menudata.py xml/menudata.xml
+	python $< > $@

Modified: grass/trunk/gui/wxpython/gui_modules/menudata.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menudata.py	2008-12-07 19:41:20 UTC (rev 34787)
+++ grass/trunk/gui/wxpython/gui_modules/menudata.py	2008-12-08 06:36:09 UTC (rev 34788)
@@ -25,6 +25,9 @@
 
 class Data:
     '''Data object that returns menu descriptions to be used in wxgui.py.'''
+    def __init__(self):
+	filename = os.getenv('GISBASE') + '/etc/wxpython/xml/menudata.xml'
+	self.tree = etree.parse(filename)
 
     def getMenuItem(self, mi):
 	if mi.tag == 'separator':
@@ -56,6 +59,15 @@
 	return list(map(self.getMenuBar, md.findall('menubar')))
 
     def GetMenu(self):
-	filename = os.getenv('GISBASE') + '/etc/wxpython/xml/menudata.xml'
-	tree = etree.parse(filename)
-	return self.getMenuData(tree.getroot())
+	return self.getMenuData(self.tree.getroot())
+
+    def PrintStrings(self, fh):
+	fh.write('menustrings = [\n')
+	for node in self.tree.getiterator():
+	    if node.tag in ['label', 'help']:
+		fh.write('     _(%r),\n' % node.text)
+	fh.write('    \'\']\n')
+
+if __name__ == "__main__":
+    import sys
+    Data().PrintStrings(sys.stdout)



More information about the grass-commit mailing list