[GRASS-SVN] r51840 - grass/trunk/locale

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 28 01:23:35 PDT 2012


Author: neteler
Date: 2012-05-28 01:23:34 -0700 (Mon, 28 May 2012)
New Revision: 51840

Modified:
   grass/trunk/locale/Makefile
   grass/trunk/locale/grass_po_stats.py
Log:
script fixes (together with martinl); added Makefile target for po file statistics

Modified: grass/trunk/locale/Makefile
===================================================================
--- grass/trunk/locale/Makefile	2012-05-28 08:04:46 UTC (rev 51839)
+++ grass/trunk/locale/Makefile	2012-05-28 08:23:34 UTC (rev 51840)
@@ -33,6 +33,10 @@
 MOD_POTFILES = find ../ -name '*.c' | grep -v '../lib' | xargs grep -l "_(\""
 WXPY_POTFILES = find ../gui/wxpython -name '*.py' | xargs grep -l "_(\""
 
+define po_stats
+GISBASE="$(RUN_GISBASE)" $(PYTHON) ./grass_po_stats.py
+endef
+
 #The xgettext utility is used to automate the creation of
 #portable message files (.po)
 pot:
@@ -76,6 +80,9 @@
 		msgfmt -c $$po; \
 	done
 
+statistics:
+	$(call po_stats)
+
 define dom_rule
 $(1)_FILES := $$(patsubst po/grass$(1)_%.po,$$(MO_DIR)/%/LC_MESSAGES/grass$(1).mo,$$(wildcard po/grass$(1)_*.po))
 $$(MO_DIR)/%/LC_MESSAGES/grass$(1).mo: po/grass$(1)_%.po

Modified: grass/trunk/locale/grass_po_stats.py
===================================================================
--- grass/trunk/locale/grass_po_stats.py	2012-05-28 08:04:46 UTC (rev 51839)
+++ grass/trunk/locale/grass_po_stats.py	2012-05-28 08:23:34 UTC (rev 51840)
@@ -19,12 +19,9 @@
 
 def main():
     directory = 'po/'
-    # TO DO CHANGE WITH GISBASE
-    outdirectory = 'po/'
-    outfilename = 'translation_status.json'
-    # TODO CHECK IF grass.try_remove CAN WORK
+    outfile = os.path.join(os.environ['GISBASE'],'locale','translation_status.json')
     try:
-        os.remove(os.path.join(directory,outfilename))
+        os.remove(outfile)
     except:
         pass
     # dictionary contaning languages and file name
@@ -73,7 +70,7 @@
             # check if some errors occurs 
             if out.find('error') != -1:
                 # TODO CHECK IF grass.warning()
-                print "WARNING: file <%s> has some problems" % flang
+                print "WARNING: file <%s> has some problems: <%s>" % (flang, out)
                 continue
             # split the output
             out = out.split(',')
@@ -81,7 +78,7 @@
             # check for each answer
             for o in out:
                 o = o.strip()
-                # each answer it's written into dictionare and
+                # each answer is written into dictionary and
                 # the value add to variable for the sum
                 if 'untranslated' in o:
                     val = int(o.split(' ')[0])
@@ -103,11 +100,16 @@
     # load dictionary into json format    
     fjson = json.dumps(output, sort_keys=True, indent=4)
     # write a string with pretty style
-    outjson = '\n'.join([l.rstrip() for l in  fjson.splitlines()])
-    # write to file!
-    fout = open(os.path.join(directory,outfilename),'w')
+    outjson = os.linesep.join([l.rstrip() for l in  fjson.splitlines()])
+    # write out file
+    fout = open(outfile,'w')
     fout.write(outjson)
+    fout.write(os.linesep)
     fout.close()
+    try:
+        os.remove("messages.mo")
+    except:
+	pass
     
 if __name__ == "__main__":
     sys.exit(main())



More information about the grass-commit mailing list