aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/Makefile
diff options
context:
space:
mode:
authorTom Wilkie <tom.wilkie@gmail.com>2007-04-13 16:46:41 +0100
committerTom Wilkie <tom.wilkie@gmail.com>2007-04-13 16:46:41 +0100
commit7771ae57e8e1678538241cba9145428d571c9b70 (patch)
treedad3badb494be292a8725c537c2be72d752afcdc /tools/python/Makefile
parent7584e4be286e43ccfda4c8435549cd22d73200b7 (diff)
downloadxen-7771ae57e8e1678538241cba9145428d571c9b70.tar.gz
xen-7771ae57e8e1678538241cba9145428d571c9b70.tar.bz2
xen-7771ae57e8e1678538241cba9145428d571c9b70.zip
Fix up locale strings for xm
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'tools/python/Makefile')
-rw-r--r--tools/python/Makefile68
1 files changed, 55 insertions, 13 deletions
diff --git a/tools/python/Makefile b/tools/python/Makefile
index ae4254c6e6..309c815352 100644
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -4,17 +4,54 @@ include $(XEN_ROOT)/tools/Rules.mk
.PHONY: all
all: build
-.PHONY: build
-build:
+# For each new supported translation, add its name here, eg 'fr_FR'
+# to cause the .po file to be built & installed, eg
+LINGUAS :=
+POPACKAGE := xen-xm
+PODIR := xen/xm/messages
+POTFILE := $(PODIR)/xen-xm.pot
+I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
+CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
+NLSDIR = /usr/share/locale
+
+.PHONY: build buildpy
+buildpy:
CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
- if which $(MSGFMT) >/dev/null ; then \
- for file in `cd ./xen/xm; find messages -name xen-xm.po`; do \
- dest=`echo "build/$$file" | \
- sed -e 's#xen-xm.po#LC_MESSAGES/xen-xm.mo#'`; \
- mkdir -p `dirname "$$dest"`; \
- $(MSGFMT) -c -o "$$dest" "xen/xm/$$file"; \
- done; \
- fi
+
+build: buildpy refresh-pot refresh-po $(CATALOGS)
+
+# NB we take care to only update the .pot file it strings have
+# actually changed. This is complicated by the embedded date
+# string, hence the sed black magic. This avoids the expensive
+# re-generation of .po files on every single build
+refresh-pot: $(I18NSRCFILES)
+ xgettext --default-domain=$(POPACAKGE) \
+ --keyword=N_ \
+ --keyword=_ \
+ -o $(POTFILE)-tmp \
+ $(I18NSRCFILES)
+ sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
+ sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
+ if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
+ rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
+ else \
+ mv $(POTFILE)-tmp $(POTFILE); \
+ rm -f $(POTFILE)-1 $(POTFILE)-2; \
+ fi
+
+refresh-po: $(POTFILE)
+ for l in $(LINGUAS); do \
+ if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; then \
+ mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
+ echo "$(MSGMERGE) of $$l.po succeeded" ; \
+ else \
+ echo "$(MSGMERGE) of $$l.po failed" ; \
+ rm -f $(PODIR)/$$l-tmp ; \
+ fi \
+ done
+
+%.mo: %.po
+ $(MSGFMT) -c -o $@ $<
.PHONY: install
ifndef XEN_PYTHON_NATIVE_INSTALL
@@ -28,8 +65,13 @@ endif
install-messages: all
if which $(MSGFMT) >/dev/null ; then \
- mkdir -p "$(DESTDIR)/usr/share/locale"; \
- cp -R build/messages/* "$(DESTDIR)/usr/share/locale/"; \
+ mkdir -p $(DESTDIR)$(NLSDIR); \
+ for l in $(LINGUAS); do \
+ $(INSTALL) -m 755 -d $(DESTDIR)$(NLSDIR)/$$l; \
+ $(INSTALL) -m 755 -d $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
+ $(INSTALL) -m 644 $(PODIR)/$$l.mo \
+ $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES/$(POPACKAGE).mo; \
+ done ; \
fi
.PHONY: test
@@ -38,4 +80,4 @@ test:
.PHONY: clean
clean:
- rm -rf build *.pyc *.pyo *.o *.a *~
+ rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS)