[PATCH] enhance Makefile for language translators

Tobias Bell tobias.bell at googlemail.com
Wed Mar 25 18:27:31 CDT 2009


# HG changeset patch
# User Tobias Bell <tobias.bell at gmail.com>
# Date 1238023635 -3600
# Node ID 439189e9a323588fb7af6afbc4ebdd964e5c570e
# Parent  3c23187a0a24a62abcadada374b5929bd374e26d
enhance Makefile for language translators

New target 'update-po' to update po-files and explicit prerequisites for
hg.pot. To update a po-file just do 'make i18n/xx.po'.

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
 export PREFIX
 PYTHON=python
 PURE=
+PYTHON_FILES:=$(shell find mercurial hgext doc -name '*.py')
+PO_FILES:=$(wildcard i18n/*.po)
 
 help:
 	@echo 'Commonly used make targets:'
@@ -15,6 +17,7 @@
 	@echo '  clean        - remove files created by other targets'
 	@echo '                 (except installed files or dist source tarball)'
 	@echo '  update-pot   - update i18n/hg.pot'
+	@echo '  update-po    - update i18n/*.po from i18n/hg.pot'
 	@echo
 	@echo 'Example for a system-wide installation under /usr/local:'
 	@echo '  make all && su -c "make install" && hg version'
@@ -76,7 +79,9 @@
 test-%:
 	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
 
-update-pot:
+update-pot: i18n/hg.pot
+
+i18n/hg.pot: $(PYTHON_FILES)
 	mkdir -p i18n
 	pygettext -d hg -p i18n --docstrings \
 	  mercurial/commands.py hgext/*.py hgext/*/__init__.py
@@ -86,10 +91,16 @@
         # parse these them even though they are not marked for
         # translation. Extracting with an explicit encoding of
         # ISO-8859-1 will make xgettext "parse" and ignore them.
-	find mercurial hgext doc -name '*.py' | xargs \
+	echo $^ | xargs \
 	  xgettext --from-code ISO-8859-1 --join --sort-by-file \
 	  -d hg -p i18n -o hg.pot
 
+update-po: $(PO_FILES)
+
+$(PO_FILES): i18n/hg.pot
+	msgmerge --no-location -U $@ $^
+
 .PHONY: help all local build doc clean install install-bin install-doc \
 	install-home install-home-bin install-home-doc dist dist-notests tests \
-	update-pot
+	update-pot update-po
+


More information about the Mercurial-devel mailing list