>From 5cbb70ebcbf141cd05fa60bf0bfa806125a56381 Mon Sep 17 00:00:00 2001 Message-Id: <5cbb70ebcbf141cd05fa60bf0bfa806125a56381.1646763369.git.julien@lepiller.eu> In-Reply-To: <37071410629a7d70c9b4e4f673f2c625d3ed4b47.1646763369.git.julien@lepiller.eu> References: <37071410629a7d70c9b4e4f673f2c625d3ed4b47.1646763369.git.julien@lepiller.eu> From: Julien Lepiller Date: Tue, 8 Mar 2022 19:11:38 +0100 Subject: [PATCH 2/3] maint: Implement translation thresholds. Do not download new translations for the cookbook and the manual when they are below 10% completion, and remove existing translations when they fall below 5%. * Makefile.am (download-po): Implement translation thresholds. --- Makefile.am | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8850c4562c..164804d96a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1066,21 +1066,35 @@ WEBLATE_REPO = https://framagit.org/tyreunom/guix-translations # form. download-po: dir=$$(mktemp -d); \ - git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations"; \ + git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations" && \ for domain in po/doc po/guix po/packages; do \ for po in "$$dir/translations/$$domain"/*.po; do \ translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \ + untranslated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f4 -d' '); \ + untranslated=$${untranslated:-0}; \ + total=$$(($$translated+$$untranslated)); \ target=$$(basename "$$po"); \ target="$$domain/$$target"; \ - if msgfmt -c "$$po" && [ "$$translated" != "0" ]; then \ + msgfmt -c "$$po"; \ + if msgfmt -c "$$po" && [ "$$translated" != "0" ] && ([ "$$domain" != "po/doc" ] || [ "$$translated" -gt $$(($$total/10)) ] || [ -f $$target ]); then \ msgfilter --no-wrap -i "$$po" cat > "$$po".tmp; \ mv "$$po".tmp "$$target"; \ echo "copied $$target."; \ else \ - echo "WARN: $$target ($$translated translated messages) was not added/updated."; \ + echo "WARN: $$target ($$translated translated messages ($$((translated/total*100))%)) was not added/updated."; \ fi; \ done; \ done; \ + for po in po/doc/*.po; do \ + translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \ + untranslated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f4 -d' '); \ + untranslated=$${untranslated:-0}; \ + total=$$(($$translated + $$untranslated)); \ + if [ "$$translated" -lt "$$(($$total/20))" ]; then \ + echo "WARN: $$po was removed because it is below the 5% threshold: $$((translated/total*100))%"; \ + rm $$po; \ + fi; \ + done; \ rm -rf "$$dir" .PHONY: download-po -- 2.34.0