Welcome to mirror list, hosted at ThFree Co, Russian Federation.

transtate.py « scripts - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f16bbb11b1b76cfa64f01d5d3538e596fcfcfbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
#
# Copyright 2012-2021 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.

# Extracts the progress of translations from the compilation
# log in easily readable form. Make sure to delete all .qm
# files beforehand.
#
# Usage: cat log | .\transtate.py

import sys
import re

def n(val):
    return (int(val) if val else 0)

if __name__ == "__main__":
    
    #--Regex matches strings like
    #
    #Updating 'mumble_zh_CN.qm'...
    #    Generated 1421 translation(s) (1145 finished and 276 unfinished)
    #    Ignored 89 untranslated source text(s)
    #    s:\dev\QtMumble\bin\lrelease.exe mumble_zh_TW.ts
    #Updating 'mumble_zh_TW.qm'...
    #    Generated 664 translation(s) (594 finished and 70 unfinished)
    #    Ignored 846 untranslated source text(s)
    
    update = re.compile(r"Updating '([\w\.]+)'\.\.\.\s+Generated (\d+) translation\(s\) \((\d+) finished and (\d+) unfinished\)(?:\s+ Ignored (\d+) untranslated source text\(s\))?")
    
    langs = 0
    s = 's'
    
    sortedbyuntranslated = sorted(update.findall(sys.stdin.read()), key=lambda s: (float(s[2]) / (n(s[1]) + n(s[4]))) if n(s[1]) else 10, reverse=True)
    
    for lang, total, finished, unfinished, ignored in sortedbyuntranslated:
        print "%s:" % lang
        
        if int(total) == 0:
            print "  Source language"
        else:
            realtotal = n(total) + n(ignored)
            percent = float(finished) / realtotal * 100
            
            print "  %d marked unfinished" % (n(unfinished))
            
            if n(ignored):
                print "  %d untranslated." % (n(ignored))

            print "  => %d%% done (total %d + %d)." % (percent, n(total), n(ignored))
        print
        langs += 1
        
    print "Number of languages: %d" % langs