[PATCH 4 of 6] let Makefile generate hg.pot and xx.mo files

Martin Geisler mg at daimi.au.dk
Sat Aug 23 08:37:23 CDT 2008


# HG changeset patch
# User Martin Geisler <mg at daimi.au.dk>
# Date 1219498339 -7200
# Node ID 68039bc804a885b94e9a6cb68d56e0cbb1b5bd6f
# Parent  f8fd0cd27bfdc986fdb2ce7456cf8813d15a1dc3
let Makefile generate hg.pot and xx.mo files

The target update-pot runs extracts strings using pygettext.py and
updates po/hg.pot. The translators can then use msgmerge to merge the
new strings in hg.pot with their xx.po file when they want to.

The update-mo target generates a locale/xx/LC_MESSAGES/hg.mo file for
each po/xx.po file present.

diff -r f8fd0cd27bfd -r 68039bc804a8 .hgignore
--- a/.hgignore	Sat Aug 23 15:32:19 2008 +0200
+++ b/.hgignore	Sat Aug 23 15:32:19 2008 +0200
@@ -27,6 +27,7 @@
 .DS_Store
 tags
 cscope.*
+locale/*/LC_MESSAGES/hg.mo
 
 syntax: regexp
 ^\.pc/
diff -r f8fd0cd27bfd -r 68039bc804a8 Makefile
--- a/Makefile	Sat Aug 23 15:32:19 2008 +0200
+++ b/Makefile	Sat Aug 23 15:32:19 2008 +0200
@@ -13,6 +13,8 @@
 	@echo '  dist         - run all tests and create a source tarball in dist/'
 	@echo '  clean        - remove files created by other targets'
 	@echo '                 (except installed files or dist source tarball)'
+	@echo '  update-pot   - update hg.pot template in po/'
+	@echo '  update-mo    - generate .mo files in locale/'
 	@echo
 	@echo 'Example for a system-wide installation under /usr/local:'
 	@echo '  make all && su -c "make install" && hg version'
@@ -74,6 +76,18 @@
 test-%:
 	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
 
+update-pot:
+	pygettext.py -d doc -p po --docstrings mercurial/commands.py hgext
+	pygettext.py -d all -p po mercurial
+	msgcat po/doc.pot po/all.pot > po/hg.pot
+	rm po/doc.pot po/all.pot
+
+locale/%/LC_MESSAGES/hg.mo: po/%.po
+	mkdir -p $(dir $@)
+	msgfmt.py -o $@ $<
+
+update-mo: $(patsubst po/%.po, locale/%/LC_MESSAGES/hg.mo, $(wildcard po/*.po))
 
 .PHONY: help all local build doc clean install install-bin install-doc \
-	install-home install-home-bin install-home-doc dist dist-notests tests
+	install-home install-home-bin install-home-doc dist dist-notests tests \
+	update-pot update-mo


More information about the Mercurial-devel mailing list