5
from translate.storage import oo
9
def dupfilter(mf, comment, fn):
10
n_all = n_translated = n_untranslated = n_same = 0
12
for oofile in mf.listsubfiles():
13
of = mf.getoofile(oofile)
14
if oofile.startswith('helpcontent2'):
15
for el in of.ooelements:
17
if len(el.lines) == 1:
19
print "WARNING: %s: no translation (%d lines)" % (helpfile, len(el.lines))
24
print "WARNING: %s: too many translations (%d lines)" % (helpfile, len(el.lines))
25
print " ", el.lines[0].project, el.lines[0].sourcefile, el.lines[0].groupid,el.lines[0].localid
27
if el.lines[0].text == el.lines[1].text \
28
and el.lines[0].helptext == el.lines[1].helptext \
29
and el.lines[0].quickhelptext == el.lines[1].quickhelptext:
32
print "Not translated: %s/%s/%s" % (el.lines[0].text, el.lines[0].helptext, el.lines[0].quickhelptext)
33
print " %s/%s/%s" % (el.lines[1].text, el.lines[1].helptext, el.lines[1].quickhelptext)
34
el.lines = [line for line in el.lines if line.languageid == "en-US"]
37
new_sources.append(str(of))
40
ratio = n_translated / float(n_all) * 100
43
print "%s: %15s: %4.1f%%, lines=%5d, translated=%5d, untranslated=%5d, same=%5d" \
44
% (comment, os.path.basename(fn), ratio, n_all, n_translated, n_untranslated, n_same)
45
print "\tremoved %d translations with same text" % n_same
48
return ''.join(new_sources)
50
if __name__ == '__main__':
51
for fn in sys.argv[1:]:
53
mf = oo.oomultifile(fn)
54
except Exception, msg:
55
sys.stdout.write("ERROR reading %s: %s\n" % (fn, msg))
59
filtered = dupfilter(mf, "help", fn)
61
fd = file(fn + '.tmp', 'w')