summaryrefslogtreecommitdiff
path: root/Makefile.am
diff options
context:
space:
mode:
authorFlorian Pelz <pelzflorian@pelzflorian.de>2025-09-01 13:51:04 +0200
committerFlorian Pelz <pelzflorian@pelzflorian.de>2025-09-30 10:37:34 +0200
commitb5054a85c1bff91ca8a55b2ca218fb5f2b9518cd (patch)
tree0ddaf3476c8d1e03805fbb57900b908431601ccd /Makefile.am
parent0509bc4cba554789ab91189c234ac8bd35be14cd (diff)
nls: Minify translation PO files.
To save a lot of disk space, keep only actually translated messages in Gettext PO files. Ignore the guix domain, which is more complicated and is tiny. * build-aux/keep-only-translated.scm: New file. * Makefile.am (download-po): Run it. Change-Id: I6442ce0ef8d62f7e48e667c766b86d0ebf9c5415
Diffstat (limited to 'Makefile.am')
-rw-r--r--Makefile.am17
1 files changed, 13 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 19aad0042e3..b29f2dfa84a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1299,8 +1299,10 @@ WEBLATE_REPO = https://codeberg.org/guix/translations
1299# Shallow clone the Git repository behind Weblate and copy files from it if 1299# Shallow clone the Git repository behind Weblate and copy files from it if
1300# they contain at least one translation, and they are well-formed (Scheme 1300# they contain at least one translation, and they are well-formed (Scheme
1301# format only), warn otherwise. Copied files are converted to a canonical 1301# format only), warn otherwise. Copied files are converted to a canonical
1302# form. 1302# form. Note: The files will be minified to reduce file size, except the
1303download-po: 1303# guix domain, because they are comparatively small and it would need more
1304# comprehensive PO file parsing abilities for plural forms.
1305download-po: guix/build/po.go
1304 dir=$$(mktemp -d); \ 1306 dir=$$(mktemp -d); \
1305 git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations" && \ 1307 git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations" && \
1306 for domain in po/doc po/guix po/packages; do \ 1308 for domain in po/doc po/guix po/packages; do \
@@ -1313,8 +1315,15 @@ download-po:
1313 target="$$domain/$$target"; \ 1315 target="$$domain/$$target"; \
1314 msgfmt -c "$$po"; \ 1316 msgfmt -c "$$po"; \
1315 if msgfmt -c "$$po" && [ "$$translated" != "0" ] && ([ "$$domain" != "po/doc" ] || [ "$$translated" -gt $$(($$total/10)) ] || [ -f $$target ]); then \ 1317 if msgfmt -c "$$po" && [ "$$translated" != "0" ] && ([ "$$domain" != "po/doc" ] || [ "$$translated" -gt $$(($$total/10)) ] || [ -f $$target ]); then \
1316 msgconv --no-wrap -o "$$po".tmp "$$po"; \ 1318 if [ "$$domain" != "po/guix" ]; then \
1317 mv "$$po".tmp "$$target"; \ 1319 $(GUILE) -L "$(top_builddir)" -L "$(top_srcdir)" \
1320 --no-auto-compile \
1321 -s "$(top_srcdir)"/build-aux/keep-only-translated.scm \
1322 "$$po" > "$$po".tmp; \
1323 else ln -s "$$po" "$$po".tmp; fi; \
1324 msgconv --no-wrap -o "$$po".tmp2 "$$po".tmp; \
1325 rm "$$po".tmp; \
1326 mv "$$po".tmp2 "$$target"; \
1318 echo "copied $$target."; \ 1327 echo "copied $$target."; \
1319 else \ 1328 else \
1320 echo "WARN: $$target ($$translated translated messages ($$((translated/total*100))%)) was not added/updated."; \ 1329 echo "WARN: $$target ($$translated translated messages ($$((translated/total*100))%)) was not added/updated."; \