Please don't put mo files in subversion
Please don't commit mo files to subversion. I show you a problem that can occur if you do that. Then I explain how you can include mo files in your package at release time.
Please don't commit mo files to subversion. Why?
- Because it's simply noise on subversion.
- Files that can be generated should not be put in subversion.
- mo files can be not up to date in subversion
PlacelessTranslationService (for Plone < 4) or zope.i18n (Plone 4) takes care of regenerating the mo file if po file modification date is greater than mo file modification date. To enable autogenerating mo files in Plone 4, you have to configure your buildout like this:
[instance]
environment-vars =
zope_i18n_compile_mo_files = true
I will show you an example of problem.
In z3c.form 2.1.0, the "Remove selected" string is translated into French if you look at the po file, but the translation doesn't show up on the page. Why?
Because there is a mo file next to the po file and it was not up to date when the release was made.
The problem in this case is that both po and mo file have the same modification date, the extracted date actually. So the mo file will not be regenerated.
You may want to include mo files in your released package because of permission issue: the user running the zope instance doesn't have write permission to the package directory. If you want to do that, generate mo files before you do the release.
I did something like that for plone.app.locales 3.3.4:
Create a MANIFEST.in file next to setup.py with the following content:
global-include *.mo
Before releasing, in the checkout tag, generate the mo files like this:
for po in `find . -name "*.po"` ; do msgfmt -o `dirname $po`/`basename $po .po`.mo $po; done
You need the gettext package to have the msgfmt command on Ubuntu.
Release as usual.
To be sure you will not commit mo files anymore, you can configure your ~/.subversion/config file like this:
[miscellany] global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.pyc *.pyo .installed.cfg bin var parts downloads *.swp develop-eggs fake-eggs eggs archgenxml.log *.egg-info *.mo build dist .mr.developer.cfg


Alternate solution
Hi Vincent,
I agree that putting .mo files in a reposo is some kind of evil. I did myself that mistake ;)
An alternate solution for people that package eggs from Windows (there are many of) : use collective.releaser made by Tarek Z., myself and others).
collective.releaser adds a cross-platform "build_mo" command to setuptools such you can release using :
$ python setup.py build_mo sdist [your options]
Maybe I'll ask Tarek to include this in distribute since it's useful to non Plone eggs too.