5
5
from translate.storage import oo
8
helpfiles = [fn for fn in mf.listsubfiles() if fn.startswith('helpcontent2')]
10
n_all = n_translated = 0
9
def statistics(mf, helpfiles, comment, fn):
10
n_all = n_translated = n_untranslated = n_same = 0
11
11
for helpfile in helpfiles:
12
12
of = mf.getoofile(helpfile)
13
#print helpfile, of.languages, len(of.ooelements)
14
13
for el in of.ooelements:
16
15
if len(el.lines) == 1:
17
#print "WARNING: %s: no translation (%d lines)" % (helpfile, len(el.lines))
17
print "WARNING: %s: no translation (%d lines)" % (helpfile, len(el.lines))
19
20
if len(el.lines) > 2:
20
print "WARNING: %s: too many translations (%d lines)" % (helpfile, len(el.lines))
22
print "WARNING: %s: too many translations (%d lines)" % (helpfile, len(el.lines))
23
print " ", el.lines[0].project, el.lines[0].sourcefile, el.lines[0].groupid,el.lines[0].localid
22
25
if el.lines[0].text == el.lines[1].text \
23
26
and el.lines[0].helptext == el.lines[1].helptext \
24
27
and el.lines[0].quickhelptext == el.lines[1].quickhelptext:
26
#print "Not translated: %s/%s/%s" % (el.lines[0].text, el.lines[0].helptext, el.lines[0].quickhelptext)
27
#print " %s/%s/%s" % (el.lines[1].text, el.lines[1].helptext, el.lines[1].quickhelptext)
30
print "Not translated: %s/%s/%s" % (el.lines[0].text, el.lines[0].helptext, el.lines[0].quickhelptext)
31
print " %s/%s/%s" % (el.lines[1].text, el.lines[1].helptext, el.lines[1].quickhelptext)
30
return n_all, n_translated
36
ratio = n_translated / float(n_all) * 100
39
print "%s: %15s: %4.1f%%, lines=%5d, translated=%5d, untranslated=%5d, same=%5d" \
40
% (comment, os.path.basename(fn), ratio, n_all, n_translated, n_untranslated, n_same)
32
43
if __name__ == '__main__':
33
44
for fn in sys.argv[1:]:
34
#sys.stderr.write("loading %s ...\n" % fn)
37
46
mf = oo.oomultifile(fn)
38
47
except Exception, msg:
39
48
sys.stdout.write("ERROR reading %s: %s\n" % (fn, msg))
41
all, translated = statistics(mf)
43
ratio = translated / float(all) * 100
46
print "%15s: %4.1f%%, lines=%d, translated=%d" % (os.path.basename(fn), ratio, all, translated)
51
helpfiles = [f for f in mf.listsubfiles() if not f.startswith('helpcontent2')]
52
statistics(mf, helpfiles, "msgs", fn)
54
helpfiles = [f for f in mf.listsubfiles() if f.startswith('helpcontent2')]
55
statistics(mf, helpfiles, "help", fn)