diff --git a/MANIFEST.in b/MANIFEST.in index 14a2b97..a6e40ef 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,9 +2,7 @@ include au-quotidien-wcs-settings.xml include wcs-au-quotidien.cfg-sample include MANIFEST.in include VERSION -include po/Makefile -include po/*.po -include po/*.pot +recursive-include auquotidien/locale *.po *.mo recursive-include apache-errors/ *.html recursive-include data/themes/ *.css *.png *.jpeg '*.jpg *.xml *.html *.js *.ezt *.gif *.otf recursive-include auquotidien/ *.py diff --git a/po/fr.po b/auquotidien/locale/fr/LC_MESSAGES/django.po similarity index 100% rename from po/fr.po rename to auquotidien/locale/fr/LC_MESSAGES/django.po diff --git a/debian/rules b/debian/rules index 951d8b1..11f9b6f 100755 --- a/debian/rules +++ b/debian/rules @@ -6,6 +6,3 @@ %: dh $@ --with python2 - -override_dh_install: - cd po && make install prefix=$(CURDIR)/debian/wcs-au-quotidien/ diff --git a/po/Makefile b/po/Makefile deleted file mode 100644 index 1bed769..0000000 --- a/po/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -POFILES=$(wildcard *.po) -MOFILES=$(POFILES:.po=.mo) -PYFILES=$(shell find ../extra/ -name '*.py' -or -name '*.ptl') - -all: $(MOFILES) - -install: all - for file in $(MOFILES); do \ - lang=`echo $$file | sed 's/\.mo//'`; \ - install -d $(prefix)/usr/share/locale/$$lang/LC_MESSAGES/; \ - install -m 0644 $$file $(prefix)/usr/share/locale/$$lang/LC_MESSAGES/auquotidien.mo; \ - done - -auquotidien.pot: $(PYFILES) - @echo "Rebuilding the pot file" - rm -f auquotidien.pot tmp.*.pot - cnt=0; - for file in $(PYFILES); do \ - cnt=$$(expr $$cnt + 1); \ - bn=$$cnt.`basename $$file`; \ - xgettext --keyword=N_ -c -L Python -o tmp.$$bn.pot $$file; \ - done - msgcat tmp.*.pot > auquotidien.pot - rm tmp.*.pot - -%.mo: %.po - msgfmt -o $@ $< - -%.po: auquotidien.pot - @echo -n "Merging auquotidien.pot and $@" - @msgmerge $@ auquotidien.pot -o $@.new - @if [ "`diff $@ $@.new | grep '[<>]' | wc -l`" -ne 2 ]; then \ - mv -f $@.new $@; \ - else \ - rm -f $@.new; \ - fi - @msgfmt --statistics $@ - diff --git a/setup.py b/setup.py index a44b017..5e1d465 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,12 @@ import os import subprocess -import distutils.core +import sys +from distutils.cmd import Command +from distutils.command.build import build as _build from distutils.command.sdist import sdist -from quixote.ptl.qx_distutils import qx_build_py +from setuptools.command.install_lib import install_lib as _install_lib from setuptools import setup VERSION = '1.20' @@ -36,6 +38,41 @@ def data_tree(destdir, sourcedir): dirs.remove('.svn') return r + +class compile_translations(Command): + description = 'compile message catalogs to MO files via django compilemessages' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + try: + from django.core.management import call_command + for path, dirs, files in os.walk('auquotidien'): + if 'locale' not in dirs: + continue + curdir = os.getcwd() + os.chdir(os.path.realpath(path)) + call_command('compilemessages') + os.chdir(curdir) + except ImportError: + sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n') + + +class build(_build): + sub_commands = [('compile_translations', None)] + _build.sub_commands + + +class install_lib(_install_lib): + def run(self): + self.run_command('compile_translations') + _install_lib.run(self) + + class eo_sdist(sdist): def run(self): @@ -58,8 +95,11 @@ setup( maintainer_email = 'fpeters@entrouvert.com', package_dir = {'auquotidien': 'auquotidien'}, packages = ['auquotidien', 'auquotidien.modules', 'auquotidien.modules.pyatom'], - cmdclass = {'build_py': qx_build_py, - 'sdist': eo_sdist}, + cmdclass={'build': build, + 'compile_translations': compile_translations, + 'install_lib': install_lib, + 'sdist': eo_sdist}, + include_package_data=True, data_files = data_tree('share/wcs/texts', 'texts') +\ data_tree('share/wcs/themes/auquotidien', 'theme') +\ data_tree('share/wcs/themes/', 'data/themes/') + \