mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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.
This commit is contained in:
parent
6386c011b2
commit
ff194cb245
1 changed files with 17 additions and 3 deletions
20
Makefile.am
20
Makefile.am
|
@ -1072,21 +1072,35 @@ WEBLATE_REPO = https://framagit.org/tyreunom/guix-translations
|
||||||
# form.
|
# form.
|
||||||
download-po:
|
download-po:
|
||||||
dir=$$(mktemp -d); \
|
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 domain in po/doc po/guix po/packages; do \
|
||||||
for po in "$$dir/translations/$$domain"/*.po; do \
|
for po in "$$dir/translations/$$domain"/*.po; do \
|
||||||
translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \
|
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 | rev | cut -f3 -d' ' | rev); \
|
||||||
|
untranslated=$${untranslated:-0}; \
|
||||||
|
total=$$(($$translated+$$untranslated)); \
|
||||||
target=$$(basename "$$po"); \
|
target=$$(basename "$$po"); \
|
||||||
target="$$domain/$$target"; \
|
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; \
|
msgfilter --no-wrap -i "$$po" cat > "$$po".tmp; \
|
||||||
mv "$$po".tmp "$$target"; \
|
mv "$$po".tmp "$$target"; \
|
||||||
echo "copied $$target."; \
|
echo "copied $$target."; \
|
||||||
else \
|
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; \
|
fi; \
|
||||||
done; \
|
done; \
|
||||||
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 | rev | cut -f3 -d' ' | rev); \
|
||||||
|
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"
|
rm -rf "$$dir"
|
||||||
.PHONY: download-po
|
.PHONY: download-po
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue