Files
godot-docs-l10n/check-completion-ratio.py
Rémi Verschelde 4f366a4767 Disable translations with less than 50% completion ratio
Since Weblate only tracks the 4.x branch, these translations can no longer be
actively worked on by the community for 3.x.

We assessed how complete they were and none of those had a good enough coverage
for the Step by Step tutorial, or the other parts of Getting Started.

The languages will keep their 4.x version online and contributors can work on
improving the completion ratio there.

Removed translations:
`cs`, `fi`, `it`, `ko`, `pl`, `zh_TW`

Adding script by @timothyqiu to check that ratio.

Co-authored-by: Haoyu Qiu <timothyqiu32@gmail.com>
2023-09-25 13:48:16 +02:00

37 lines
1021 B
Python

# /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)