~ubuntu-branches/ubuntu/karmic/openoffice.org-l10n/karmic

« back to all changes in this revision

Viewing changes to debian/gsistat.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-04-27 19:29:22 UTC
  • Revision ID: james.westby@ubuntu.com-20060427192922-2dburxv3b63f8v0u
Tags: 2.0.2-2ubuntu5
* Copy of the openoffice.org source.
  - debian/control.in: Change source name.
  - debian/changelog: Change source name.
  - debian/control: Regenerate control file.
* Add kurdish translations exported from Rosetta (2006-04-18).
* Workaround bad message strings in recently included GSI files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import sys
5
5
from translate.storage import oo
6
6
 
7
 
def statistics(mf):
8
 
    helpfiles = [fn for fn in mf.listsubfiles() if fn.startswith('helpcontent2')]
9
 
    #print helpfiles
10
 
    n_all = n_translated = 0
 
7
debug = False
 
8
 
 
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:
15
14
            n_all += 1
16
15
            if len(el.lines) == 1:
17
 
                #print "WARNING: %s: no translation (%d lines)" % (helpfile, len(el.lines))
 
16
                if debug:
 
17
                    print "WARNING: %s: no translation (%d lines)" % (helpfile, len(el.lines))
 
18
                n_untranslated += 1
18
19
                continue
19
20
            if len(el.lines) > 2:
20
 
                print "WARNING: %s: too many translations (%d lines)" % (helpfile, len(el.lines))
 
21
                if debug:
 
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
21
24
                continue
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:
25
 
                pass
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)
 
28
                n_same += 1
 
29
                if debug:
 
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)
28
32
            else:
29
33
                n_translated += 1
30
 
    return n_all, n_translated
 
34
 
 
35
    try:
 
36
        ratio = n_translated / float(n_all) * 100
 
37
    except:
 
38
        ratio = 0.0
 
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)
 
41
    sys.stdout.flush()
31
42
 
32
43
if __name__ == '__main__':
33
44
    for fn in sys.argv[1:]:
34
 
        #sys.stderr.write("loading %s ...\n" % fn)
35
 
        #sys.stderr.flush()
36
45
        try:
37
46
            mf = oo.oomultifile(fn)
38
47
        except Exception, msg:
39
48
            sys.stdout.write("ERROR reading %s: %s\n" % (fn, msg))
40
49
            sys.stdout.flush()
41
 
        all, translated = statistics(mf)
42
 
        try:
43
 
            ratio = translated / float(all) * 100
44
 
        except:
45
 
            ratio = 0.0
46
 
        print "%15s: %4.1f%%, lines=%d, translated=%d" % (os.path.basename(fn), ratio, all, translated)
47
 
        sys.stdout.flush()
 
50
 
 
51
        helpfiles = [f for f in mf.listsubfiles() if not f.startswith('helpcontent2')]
 
52
        statistics(mf, helpfiles, "msgs", fn)
 
53
 
 
54
        helpfiles = [f for f in mf.listsubfiles() if f.startswith('helpcontent2')]
 
55
        statistics(mf, helpfiles, "help", fn)