From 8021400c6006bda4de613b58107254807f3c4706 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 1 Mar 2009 13:16:15 +0000 Subject: [PATCH] Create .mo files during build, not install The .mo files are now updated by "make". This means they only get regenerated when necessary and the process doesn't fail if the user has a release (with .mo files) but not msgfmt. --- Makefile | 10 +++++++--- setup.py | 9 ++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 79d3742..ba0ce0d 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,19 @@ PYTHON=python +MO = $(shell find locale -name '*.po' | sed -e 's/\.po/\.mo/') PY = $(shell find zeroinstall -name '*.py') -GLADE = $(shell find zeroinstall -name '*.glade' | sed -e 's/.glade/&.h/') +GLADE = $(shell find zeroinstall -name '*.glade' | sed -e 's/\.glade/&.h/') -all: +all: $(MO) $(PYTHON) setup.py build -install: +install: all $(PYTHON) setup.py install +%.mo: %.po + msgfmt -o "$@" "$<" + %.glade.h: %.glade intltool-extract --type=gettext/glade --update "$<" diff --git a/setup.py b/setup.py index 3dd5ad9..5f6d6d0 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from distutils.command.build_py import build_py from distutils.command.install import install from distutils.command.install_lib import install_lib from distutils.command.install_data import install_data -import os, subprocess +import os, subprocess, sys import glob import zeroinstall @@ -45,12 +45,7 @@ class install_data_locale(install_data): def _compile_po_files(self): i18nfiles = [] - for directory in glob.glob("locale/*/LC_MESSAGES"): - po = os.path.join(directory, 'zero-install.po') - mo = os.path.join(directory, 'zero-install.mo') - print 'compiling %s -> %s' % (po, mo) - if subprocess.call(['msgfmt', '-o', mo, po]) != 0: - raise 'Error while running msgfmt on %s' % directory + for mo in glob.glob("locale/*/LC_MESSAGES/zero-install.mo"): dest = os.path.dirname(os.path.join('share', mo)) i18nfiles.append((dest, [mo])) return i18nfiles -- 2.11.4.GIT