[PATCH 3 of 5] i18n: let Makefile generate hg.pot and xx.mo files

Martin Geisler mg at daimi.au.dk
Fri Jan 9 18:26:43 CST 2009


# HG changeset patch
# User Martin Geisler <mg at daimi.au.dk>
# Date 1231547108 -3600
# Node ID fe353e671685241b29f8c259c05b27a17c572fab
# Parent  d775f2521088ea0d69e73f79d68c9e5915f123a3
i18n: 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.

The MANIFEST target now also depend on update-mo and includes the
hg.mo files.

diff -r d775f2521088 -r fe353e671685 .hgignore
--- a/.hgignore	Sat Jan 10 01:23:57 2009 +0100
+++ b/.hgignore	Sat Jan 10 01:25:08 2009 +0100
@@ -27,6 +27,8 @@
 .DS_Store
 tags
 cscope.*
+po/hg.pot
+locale/*/LC_MESSAGES/hg.mo
 
 syntax: regexp
 ^\.pc/
diff -r d775f2521088 -r fe353e671685 Makefile
--- a/Makefile	Sat Jan 10 01:23:57 2009 +0100
+++ b/Makefile	Sat Jan 10 01:25:08 2009 +0100
@@ -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'
@@ -58,10 +60,11 @@
 MANIFEST-doc:
 	$(MAKE) -C doc MANIFEST
 
-MANIFEST: MANIFEST-doc
+MANIFEST: MANIFEST-doc update-mo
 	hg manifest > MANIFEST
 	echo mercurial/__version__.py >> MANIFEST
 	cat doc/MANIFEST >> MANIFEST
+	for f in locale/*/LC_MESSAGES/hg.mo; do echo "$$f" >> MANIFEST; done
 
 dist:	tests dist-notests
 
@@ -74,6 +77,20 @@
 test-%:
 	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
 
+update-pot:
+	mkdir -p po
+	pygettext.py -d doc -p po --docstrings \
+	mercurial/commands.py hgext/*.py hgext/*/__init__.py
+	pygettext.py -d all -p po mercurial hgext doc
+	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