[libreoffice] 01/01: remove gsistat; add quick'n'dirty script to count % of translations' .po files

Rene Engelhard rene at moszumanska.debian.org
Sat Sep 9 16:03:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

rene pushed a commit to branch master
in repository libreoffice.

commit 54577e3f0f7f67bcd93ddcc2f942f8ec7dcc8e37
Author: Rene Engelhard <rene at rene-engelhard.de>
Date:   Sat Sep 9 18:01:16 2017 +0200

    remove gsistat; add quick'n'dirty script to count % of translations' .po files
---
 scripts/gsistat.py  | 59 -----------------------------------------------------
 scripts/stat_pos.sh | 32 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 59 deletions(-)

diff --git a/scripts/gsistat.py b/scripts/gsistat.py
deleted file mode 100755
index 879d450..0000000
--- a/scripts/gsistat.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#! /usr/bin/python
-
-import os
-import sys
-from translate.storage import oo
-
-debug = False
-
-def statistics(mf, helpfiles, comment, fn):
-    n_all = n_translated = n_untranslated = n_same = 0
-    for helpfile in helpfiles:
-        of = mf.getoofile(helpfile)
-        try:
-            elements = of.ooelements
-        except:
-            elements = of.units
-        for el in elements:
-            n_all += 1
-            if len(el.lines) == 1:
-                if debug:
-                    print "WARNING: %s: no translation (%d lines)" % (helpfile, len(el.lines))
-                n_untranslated += 1
-                continue
-            if len(el.lines) > 2:
-                if debug:
-                    print "WARNING: %s: too many translations (%d lines)" % (helpfile, len(el.lines))
-                    print "   ", el.lines[0].project, el.lines[0].sourcefile, el.lines[0].groupid,el.lines[0].localid
-                continue
-            if el.lines[0].text == el.lines[1].text \
-               and el.lines[0].helptext == el.lines[1].helptext \
-               and el.lines[0].quickhelptext == el.lines[1].quickhelptext:
-                n_same += 1
-                if debug:
-                    print "Not translated: %s/%s/%s" % (el.lines[0].text, el.lines[0].helptext, el.lines[0].quickhelptext)
-                    print "                %s/%s/%s" % (el.lines[1].text, el.lines[1].helptext, el.lines[1].quickhelptext)
-            else:
-                n_translated += 1
-
-    try:
-        ratio = n_translated / float(n_all) * 100
-    except:
-        ratio = 0.0
-    print "%s: %15s: %4.1f%%, lines=%5d, translated=%5d, untranslated=%5d, same=%5d" \
-          % (comment, os.path.basename(fn), ratio, n_all, n_translated, n_untranslated, n_same)
-    sys.stdout.flush()
-
-if __name__ == '__main__':
-    for fn in sys.argv[1:]:
-        try:
-            mf = oo.oomultifile(fn)
-        except Exception, msg:
-            sys.stdout.write("ERROR reading %s: %s\n" % (fn, msg))
-	    sys.stdout.flush()
-
-        helpfiles = [f for f in mf.listsubfiles() if not f.startswith('helpcontent2')]
-        statistics(mf, helpfiles, "msgs", fn)
-
-        helpfiles = [f for f in mf.listsubfiles() if f.startswith('helpcontent2')]
-        statistics(mf, helpfiles, "help", fn)
diff --git a/scripts/stat_pos.sh b/scripts/stat_pos.sh
new file mode 100755
index 0000000..0a3c5ae
--- /dev/null
+++ b/scripts/stat_pos.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -e
+
+# Quick and dirty script to stat the LO translations/ pos wrt % translated
+# FIXME: maybe use pocount from translate-toolkit
+
+# Author: Rene Engelhard <rene at debian.org>
+# (C) 2017 Software in the Public Interest, Inc.
+
+cd translations/source
+ 
+for l in `ls -1`; do
+	# 23:36 <@cloph> no - but you can do a brute-force method of just counting msgid and comparing that with »msgstr ""« matches.
+	# 23:37 <@cloph> While that ignores multiline strings, there aren't too many and should work as a rough estimate
+	msgid_count=$(grep msgid `find $l -name "*.po"` | wc -l)
+	msgstr_count=$(grep msgstr `find $l -name "*.po"` | wc -l)
+	empty_msgstr_count=$(grep msgstr\ \"\" `find $l -name "*.po"` | wc -l)
+	p=$((100*$empty_msgstr_count/$msgid_count))
+	echo "$l: $msgid_count strings, $(($msgid_count-$empty_msgstr_count))/$msgid_count translated; $empty_msgstr_count/$msgid_count untranslated"
+	if test $msgid_count -lt 50000; then
+		echo "$l: no help translations"
+	fi
+	echo "$l: $((100-$p))% translated, $p% untranslated"
+
+	if test $p -lt 20; then
+		langs="$langs $l"
+	fi
+done
+
+echo "languages over 80% translated:"
+echo $langs

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openoffice/libreoffice.git



More information about the Pkg-openoffice-commits mailing list