Skip to content

Commit

Permalink
Add a small script to pull translation state from compile logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hacst committed Nov 12, 2012
1 parent 1922df7 commit becbda5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions scripts/transtate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
# 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




0 comments on commit becbda5

Please sign in to comment.