2018-07-03 19:43:34 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-07-24 22:44:49 +00:00
|
|
|
import os
|
2015-06-30 16:57:25 +00:00
|
|
|
import sys
|
2018-07-24 22:44:49 +00:00
|
|
|
import twlang
|
|
|
|
|
2018-07-25 07:15:09 +00:00
|
|
|
os.chdir(os.path.dirname(__file__) + "/../..")
|
2015-06-30 16:57:25 +00:00
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
2020-12-02 14:22:26 +00:00
|
|
|
langs = sys.argv[1:]
|
2015-06-30 16:57:25 +00:00
|
|
|
else:
|
2020-12-02 14:22:26 +00:00
|
|
|
langs = twlang.languages()
|
2015-06-30 16:57:25 +00:00
|
|
|
local = twlang.localizes()
|
|
|
|
table = []
|
|
|
|
for lang in langs:
|
2020-12-02 14:22:26 +00:00
|
|
|
trans = twlang.translations(lang)
|
|
|
|
empty = 0
|
|
|
|
supported = 0
|
|
|
|
unused = 0
|
|
|
|
for tran, (_, expr, _) in trans.items():
|
|
|
|
if not expr:
|
|
|
|
empty += 1
|
|
|
|
else:
|
|
|
|
if tran in local:
|
|
|
|
supported += 1
|
|
|
|
else:
|
|
|
|
unused += 1
|
|
|
|
table.append([lang, len(trans), empty, len(local)-supported, unused])
|
2015-06-30 16:57:25 +00:00
|
|
|
|
|
|
|
table.sort(key=lambda l: l[3])
|
|
|
|
table = [["filename", "total", "empty", "missing", "unused"]] + table
|
|
|
|
s = [[str(e) for e in row] for row in table]
|
|
|
|
lens = [max(map(len, col)) for col in zip(*s)]
|
|
|
|
fmt = " ".join("{{:{}}}".format(x) for x in lens)
|
|
|
|
t = [fmt.format(*row) for row in s]
|
|
|
|
print("\n".join(t))
|