diff options
| author | Julien Lepiller <julien@lepiller.eu> | 2021-04-18 23:56:48 +0200 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-05-03 09:29:44 -0400 |
| commit | 283d4960a47e51bfab5466ca857cf3eddeacbe2e (patch) | |
| tree | 528f0d0b2e8950104c2d4bf1b018fd2d51b9dab0 /Makefile.am | |
| parent | ce5026b9f44b72ff2571a1d259d1abd8658cd1f4 (diff) | |
Makefile: Reimplement `download-po` target.
The weblate API rate limit is very close to the number of files we need
to download. The previous implementation did not add new translations.
* Makefile.am (download-po): Update target.
(make-download-po-rule, make-check-po-rule): Remove functions.
Diffstat (limited to 'Makefile.am')
| -rw-r--r-- | Makefile.am | 92 |
1 files changed, 24 insertions, 68 deletions
diff --git a/Makefile.am b/Makefile.am index 8d059eb0335..941ab052346 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -971,76 +971,32 @@ cuirass-jobs: $(GOBJECTS) | |||
| 971 | 971 | ||
| 972 | # Downloading up-to-date PO files. | 972 | # Downloading up-to-date PO files. |
| 973 | 973 | ||
| 974 | # make-download-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX] | 974 | WEBLATE_REPO = https://framagit.org/tyreunom/guix-translations |
| 975 | define make-download-po-rule | 975 | |
| 976 | 976 | # Shallow clone the Git repository behind Weblate and copy files from it if | |
| 977 | download-po.$(1): | 977 | # they contain at least one translation, and they are well-formed (Scheme |
| 978 | if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then \ | 978 | # format only), warn otherwise. Copied files are converted to a canonical |
| 979 | LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ; \ | 979 | # form. |
| 980 | else \ | 980 | download-po: |
| 981 | LINGUAS="`(cd $(top_srcdir)/$(2); \ | 981 | dir=$$(mktemp -d); \ |
| 982 | for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ; \ | 982 | git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations"; \ |
| 983 | fi ; \ | 983 | for domain in po/doc po/guix po/packages; do \ |
| 984 | for lang in $$$$LINGUAS; do \ | 984 | for po in "$$dir/translations/$$domain"/*.po; do \ |
| 985 | if wget -nv -O "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" \ | 985 | translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \ |
| 986 | "https://translate.fedoraproject.org/api/translations/guix/$(1)/$$$$lang/file/" ; \ | 986 | target=$$(basename "$$po"); \ |
| 987 | then \ | 987 | target="$$domain/$$target"; \ |
| 988 | msgfilter --no-wrap -i "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" \ | 988 | if msgfmt -c "$$po" && [ "$$translated" != "0" ]; then \ |
| 989 | cat > "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp2" ; \ | 989 | msgfilter --no-wrap -i "$$po" cat > "$$po".tmp; \ |
| 990 | rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ; \ | 990 | mv "$$po".tmp "$$target"; \ |
| 991 | mv "$(top_srcdir)/$(2)/$(3)$$$$lang.po"{.tmp2,} ; \ | 991 | echo "copied $$target."; \ |
| 992 | else \ | 992 | else \ |
| 993 | rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ; \ | 993 | echo "WARN: $$target ($$translated translated messages) was not added/updated."; \ |
| 994 | fi ; \ | 994 | fi; \ |
| 995 | done | 995 | done; \ |
| 996 | 996 | done; \ | |
| 997 | .PHONY: download-po.$(1) | 997 | rm -rf "$$dir" |
| 998 | |||
| 999 | endef | ||
| 1000 | |||
| 1001 | # Checking po files for issues. This is useful to run after downloading new | ||
| 1002 | # po files. | ||
| 1003 | |||
| 1004 | # make-check-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX] | ||
| 1005 | define make-check-po-rule | ||
| 1006 | |||
| 1007 | check-po.$(1): | ||
| 1008 | if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then \ | ||
| 1009 | LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ; \ | ||
| 1010 | else \ | ||
| 1011 | LINGUAS="`(cd $(top_srcdir)/$(2); \ | ||
| 1012 | for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ; \ | ||
| 1013 | fi ; \ | ||
| 1014 | for lang in $$$$LINGUAS; do \ | ||
| 1015 | if [ -f "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ]; \ | ||
| 1016 | then \ | ||
| 1017 | if ! msgfmt -c "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ; \ | ||
| 1018 | then \ | ||
| 1019 | exit 1 ; \ | ||
| 1020 | fi ; \ | ||
| 1021 | fi ; \ | ||
| 1022 | done | ||
| 1023 | |||
| 1024 | .PHONY: check-po.$(1) | ||
| 1025 | |||
| 1026 | endef | ||
| 1027 | |||
| 1028 | $(eval $(call make-download-po-rule,documentation-cookbook,po/doc,guix-cookbook.)) | ||
| 1029 | $(eval $(call make-download-po-rule,documentation-manual,po/doc,guix-manual.)) | ||
| 1030 | $(eval $(call make-download-po-rule,guix,po/guix)) | ||
| 1031 | $(eval $(call make-download-po-rule,packages,po/packages)) | ||
| 1032 | |||
| 1033 | $(eval $(call make-check-po-rule,documentation-cookbook,po/doc,guix-cookbook.)) | ||
| 1034 | $(eval $(call make-check-po-rule,documentation-manual,po/doc,guix-manual.)) | ||
| 1035 | $(eval $(call make-check-po-rule,guix,po/guix)) | ||
| 1036 | $(eval $(call make-check-po-rule,packages,po/packages)) | ||
| 1037 | |||
| 1038 | download-po: $(foreach domain,guix packages documentation-manual documentation-cookbook,download-po.$(domain)) | ||
| 1039 | .PHONY: download-po | 998 | .PHONY: download-po |
| 1040 | 999 | ||
| 1041 | check-po: $(foreach domain,guix packages documentation-manual documentation-cookbook,check-po.$(domain)) | ||
| 1042 | .PHONY: check-po | ||
| 1043 | |||
| 1044 | ## -------------- ## | 1000 | ## -------------- ## |
| 1045 | ## Silent rules. ## | 1001 | ## Silent rules. ## |
| 1046 | ## -------------- ## | 1002 | ## -------------- ## |
