mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-12 06:06:53 -05:00
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.
This commit is contained in:
parent
ce5026b9f4
commit
283d4960a4
1 changed files with 23 additions and 67 deletions
90
Makefile.am
90
Makefile.am
|
@ -971,76 +971,32 @@ cuirass-jobs: $(GOBJECTS)
|
||||||
|
|
||||||
# Downloading up-to-date PO files.
|
# Downloading up-to-date PO files.
|
||||||
|
|
||||||
# make-download-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX]
|
WEBLATE_REPO = https://framagit.org/tyreunom/guix-translations
|
||||||
define make-download-po-rule
|
|
||||||
|
|
||||||
download-po.$(1):
|
# Shallow clone the Git repository behind Weblate and copy files from it if
|
||||||
if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then \
|
# they contain at least one translation, and they are well-formed (Scheme
|
||||||
LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ; \
|
# format only), warn otherwise. Copied files are converted to a canonical
|
||||||
else \
|
# form.
|
||||||
LINGUAS="`(cd $(top_srcdir)/$(2); \
|
download-po:
|
||||||
for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ; \
|
dir=$$(mktemp -d); \
|
||||||
fi ; \
|
git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations"; \
|
||||||
for lang in $$$$LINGUAS; do \
|
for domain in po/doc po/guix po/packages; do \
|
||||||
if wget -nv -O "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" \
|
for po in "$$dir/translations/$$domain"/*.po; do \
|
||||||
"https://translate.fedoraproject.org/api/translations/guix/$(1)/$$$$lang/file/" ; \
|
translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \
|
||||||
then \
|
target=$$(basename "$$po"); \
|
||||||
msgfilter --no-wrap -i "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" \
|
target="$$domain/$$target"; \
|
||||||
cat > "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp2" ; \
|
if msgfmt -c "$$po" && [ "$$translated" != "0" ]; then \
|
||||||
rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ; \
|
msgfilter --no-wrap -i "$$po" cat > "$$po".tmp; \
|
||||||
mv "$(top_srcdir)/$(2)/$(3)$$$$lang.po"{.tmp2,} ; \
|
mv "$$po".tmp "$$target"; \
|
||||||
else \
|
echo "copied $$target."; \
|
||||||
rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ; \
|
else \
|
||||||
fi ; \
|
echo "WARN: $$target ($$translated translated messages) was not added/updated."; \
|
||||||
done
|
fi; \
|
||||||
|
done; \
|
||||||
.PHONY: download-po.$(1)
|
done; \
|
||||||
|
rm -rf "$$dir"
|
||||||
endef
|
|
||||||
|
|
||||||
# Checking po files for issues. This is useful to run after downloading new
|
|
||||||
# po files.
|
|
||||||
|
|
||||||
# make-check-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX]
|
|
||||||
define make-check-po-rule
|
|
||||||
|
|
||||||
check-po.$(1):
|
|
||||||
if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then \
|
|
||||||
LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ; \
|
|
||||||
else \
|
|
||||||
LINGUAS="`(cd $(top_srcdir)/$(2); \
|
|
||||||
for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ; \
|
|
||||||
fi ; \
|
|
||||||
for lang in $$$$LINGUAS; do \
|
|
||||||
if [ -f "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ]; \
|
|
||||||
then \
|
|
||||||
if ! msgfmt -c "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ; \
|
|
||||||
then \
|
|
||||||
exit 1 ; \
|
|
||||||
fi ; \
|
|
||||||
fi ; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.PHONY: check-po.$(1)
|
|
||||||
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call make-download-po-rule,documentation-cookbook,po/doc,guix-cookbook.))
|
|
||||||
$(eval $(call make-download-po-rule,documentation-manual,po/doc,guix-manual.))
|
|
||||||
$(eval $(call make-download-po-rule,guix,po/guix))
|
|
||||||
$(eval $(call make-download-po-rule,packages,po/packages))
|
|
||||||
|
|
||||||
$(eval $(call make-check-po-rule,documentation-cookbook,po/doc,guix-cookbook.))
|
|
||||||
$(eval $(call make-check-po-rule,documentation-manual,po/doc,guix-manual.))
|
|
||||||
$(eval $(call make-check-po-rule,guix,po/guix))
|
|
||||||
$(eval $(call make-check-po-rule,packages,po/packages))
|
|
||||||
|
|
||||||
download-po: $(foreach domain,guix packages documentation-manual documentation-cookbook,download-po.$(domain))
|
|
||||||
.PHONY: download-po
|
.PHONY: download-po
|
||||||
|
|
||||||
check-po: $(foreach domain,guix packages documentation-manual documentation-cookbook,check-po.$(domain))
|
|
||||||
.PHONY: check-po
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
## Silent rules. ##
|
## Silent rules. ##
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|
Loading…
Reference in a new issue