Переглянути джерело

script fixes (together with martinl); added Makefile target for po file statistics

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51840 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 13 роки тому
батько
коміт
d4a7bf4a74
2 змінених файлів з 19 додано та 10 видалено
  1. 7 0
      locale/Makefile
  2. 12 10
      locale/grass_po_stats.py

+ 7 - 0
locale/Makefile

@@ -33,6 +33,10 @@ LIB_POTFILES = find ../lib \( -name "*.c" -o -name "*.py" \) | xargs grep -l "_(
 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 @@ verify:
 		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

+ 12 - 10
locale/grass_po_stats.py

@@ -19,12 +19,9 @@ import json
 
 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 @@ def main():
             # 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 @@ def main():
             # 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 @@ def main():
     # 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())