Преглед на файлове

Generate dummy Python file containing menu strings for translation

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34788 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements преди 16 години
родител
ревизия
9bfef78e8f
променени са 2 файла, в които са добавени 18 реда и са изтрити 3 реда
  1. 3 0
      gui/wxpython/Makefile
  2. 15 3
      gui/wxpython/gui_modules/menudata.py

+ 3 - 0
gui/wxpython/Makefile

@@ -17,6 +17,7 @@ install_scripts:
 	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)/scripts/%: scripts/%
 $(ETCDIR)/%: %
 	$(INSTALL_DATA) $< $@
 
+menustrings.py: gui_modules/menudata.py xml/menudata.xml
+	python $< > $@

+ 15 - 3
gui/wxpython/gui_modules/menudata.py

@@ -25,6 +25,9 @@ except ImportError:
 
 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 @@ class Data:
 	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)