Skip to content

Commit

Permalink
Add script to check completion ratio per section
Browse files Browse the repository at this point in the history
Co-authored-by: Haoyu Qiu <[email protected]>
  • Loading branch information
akien-mga and timothyqiu committed Sep 25, 2023
1 parent 0a28f34 commit 7fdd05c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions check-completion-ratio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# /usr/bin/env python3

import polib


def check(lang):
pofile = polib.pofile("./weblate/{}.po".format(lang))

if pofile.percent_translated() > 50:
return
print("==== {} - {}% translated ====".format(lang, pofile.percent_translated()))

statistic = {} # section -> [complete, incomplete]

for entry in pofile:
for occ in entry.occurrences:
if "<rst_epilog>" in occ[0]:
continue

path = occ[0].removeprefix("../../docs/")
section = "/".join(path.split("/", maxsplit=2)[:-1])
statistic.setdefault(section, [0, 0])
if entry.translated():
statistic[section][0] += 1
else:
statistic[section][1] += 1

for k, v in sorted(statistic.items()):
ratio = v[0] / (v[0] + v[1])
if ratio > 0.5:
print("{:5.1f}\t{}".format(100 * ratio, k or "<root>"))


with open("build_langs.txt") as f:
for lang in f.read().splitlines():
check(lang)

0 comments on commit 7fdd05c

Please sign in to comment.