Msgfmt in distutils?
Hi, Distutils has made my life easier as an python application author and packager for some time but when it comes to generating and distributing message catalogues for translations, things get unexpectedly tricky. It would be nice to be able to do something like, --------- from distutils.core import setup setup(name="foo", version="1.0", description="A handy, translated application", ... po_files = [('share/locales', ['po/*.po'])] ) ---------- and have distutils do the right thing with the .po files at build time (generate .mo files from them) and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them). My big question is, are there plans to add msgfmt functionality into distutils? Googling tells me there was some discussion about this back in 2003 but I can't find any sign of progress since then. Regards, -- Andy Price
Andrew Price wrote:
Hi,
Distutils has made my life easier as an python application author and packager for some time but when it comes to generating and distributing message catalogues for translations, things get unexpectedly tricky.
It would be nice to be able to do something like,
--------- from distutils.core import setup
setup(name="foo", version="1.0", description="A handy, translated application", ... po_files = [('share/locales', ['po/*.po'])] ) ----------
and have distutils do the right thing with the .po files at build time (generate .mo files from them) and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them).
My big question is, are there plans to add msgfmt functionality into distutils? Googling tells me there was some discussion about this back in 2003 but I can't find any sign of progress since then.
This has been a big deal for some applications I work on. Our first cut was to add new Build and InstallData command classes. I'm not happy with how that works at all. Our next pass is going to be moving the build scripts to paver since that will make it easy to both declaratively specify what po files exist and writing the imperative task that actually installs them. http://www.blueskyonmars.com/projects/paver/ -Toshio
-On [20081001 16:28], Toshio Kuratomi (a.badger@gmail.com) wrote:
and have distutils do the right thing with the .po files at build time (generate .mo files from them) and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them).
[snip]
This has been a big deal for some applications I work on. Our first cut was to add new Build and InstallData command classes.
Actually with Babel (http://babel.edgewall.org/) that's all handled.
--
Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven wrote:
-On [20081001 16:28], Toshio Kuratomi (a.badger@gmail.com) wrote:
and have distutils do the right thing with the .po files at build time (generate .mo files from them) and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them).
[snip]
This has been a big deal for some applications I work on. Our first cut was to add new Build and InstallData command classes.
Actually with Babel (http://babel.edgewall.org/) that's all handled.
That's good to know. One of our Turbogears applications uses Babel and it definitely doesn't install to the right place. I'd love to fix it to take advantage of Babel' properly. Would you be kind enough to point me documentation on how to get Babel to install locale files? Looking at the babel website, I only see documentation up to building the message catalogs. If the install portion is integrated into setuptools is there something I might have to configure in setup() to tell babel/setuptools what directory to use? -Toshio
-On [20081001 20:26], Toshio Kuratomi (a.badger@gmail.com) wrote:
That's good to know. One of our Turbogears applications uses Babel and it definitely doesn't install to the right place. I'd love to fix it to take advantage of Babel' properly. Would you be kind enough to point me documentation on how to get Babel to install locale files?
Leaving aside the extractors for now, as far as I know either adding Babel
to the requires or adding an import babel should suffice.
You should get, when you do python setup.py --help-commands, a few options
for catalog management.
A simple compile_catalog (perhaps with the force flag) should create .mo
files, then follow up with a normal build and install. Currently the locale
catalog files are packaged inside the eggs.
Feature requests and all that all welcome at the Babel site. :)
--
Jeroen Ruigrok van der Werven
Jeroen Ruigrok van der Werven wrote:
-On [20081001 20:26], Toshio Kuratomi (a.badger@gmail.com) wrote:
That's good to know. One of our Turbogears applications uses Babel and it definitely doesn't install to the right place. I'd love to fix it to take advantage of Babel' properly. Would you be kind enough to point me documentation on how to get Babel to install locale files?
Leaving aside the extractors for now, as far as I know either adding Babel to the requires or adding an import babel should suffice.
You should get, when you do python setup.py --help-commands, a few options for catalog management.
A simple compile_catalog (perhaps with the force flag) should create .mo files, then follow up with a normal build and install. Currently the locale catalog files are packaged inside the eggs.
Ah. I think you missed this from the original poster::
and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them).
As for what I'm seeing... It doesn't look like my locales are being installed at all if I just rely on babel. Perhaps you are putting the mo files into package data normally and then the standard install_data is putting it in the egg? This definitely isn't what we want and is why I'm so gung-ho about moving over to paver.
Feature requests and all that all welcome at the Babel site. :)
I suppose it depends on whether installation of .mo files is part of Babel's goal. Since I only saw information about extracting messages, creating, building, and maintaining catalogs I didn't know if that was part of what babel was aiming for. Thanks! -Toshio
On Oct 1, 2008, at 11:25 AM, Toshio Kuratomi wrote:
Jeroen Ruigrok van der Werven wrote:
-On [20081001 16:28], Toshio Kuratomi (a.badger@gmail.com) wrote:
and have distutils do the right thing with the .po files at build time (generate .mo files from them) and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them).
[snip]
This has been a big deal for some applications I work on. Our first cut was to add new Build and InstallData command classes.
Actually with Babel (http://babel.edgewall.org/) that's all handled.
That's good to know. One of our Turbogears applications uses Babel and it definitely doesn't install to the right place. I'd love to fix it to take advantage of Babel' properly. Would you be kind enough to point me documentation on how to get Babel to install locale files? Looking at the babel website, I only see documentation up to building the message catalogs. If the install portion is integrated into setuptools is there something I might have to configure in setup() to tell babel/ setuptools what directory to use?
Once you have Babel generating .mo files, all you'll need is a package_data entry for them, e.g.: package_data={'foo': ['i18n/*/LC_MESSAGES/*.mo']}, then the catalogs will make it into the final sdist/egg and be included during an installation. -- Philip Jenvey
Philip Jenvey wrote:
On Oct 1, 2008, at 11:25 AM, Toshio Kuratomi wrote:
Jeroen Ruigrok van der Werven wrote:
-On [20081001 16:28], Toshio Kuratomi (a.badger@gmail.com) wrote:
and have distutils do the right thing with the .po files at build time (generate .mo files from them) and at install time (install them into PREFIX/share/locales/LC_MESSAGES/, or wherever the distribution is configured to put them).
[snip]
This has been a big deal for some applications I work on. Our first cut was to add new Build and InstallData command classes.
Actually with Babel (http://babel.edgewall.org/) that's all handled.
That's good to know. One of our Turbogears applications uses Babel and it definitely doesn't install to the right place. I'd love to fix it to take advantage of Babel' properly. Would you be kind enough to point me documentation on how to get Babel to install locale files? Looking at the babel website, I only see documentation up to building the message catalogs. If the install portion is integrated into setuptools is there something I might have to configure in setup() to tell babel/setuptools what directory to use?
Once you have Babel generating .mo files, all you'll need is a package_data entry for them, e.g.:
package_data={'foo': ['i18n/*/LC_MESSAGES/*.mo']},
then the catalogs will make it into the final sdist/egg and be included during an installation.
Thanks! This isn't quite what I was asking, though. the orignal poster was asking how to install the catalogs into /usr/share/locale, the proper directory on a Linux system. I thouoght babel was able to do that but it seems babel currently just handles the creation and maintenance of the message catalogs. Which is a huge thing! I just was hoping to get rid of my ugly code to move the catalogs into the system directory. -Toshio
Hi, On 01/10/08 15:35, Jeroen Ruigrok van der Werven wrote:
-On [20081001 16:28], Toshio Kuratomi (a.badger@gmail.com) wrote:
This has been a big deal for some applications I work on. Our first cut was to add new Build and InstallData command classes.
Actually with Babel (http://babel.edgewall.org/) that's all handled.
I came across Babel during my search for a solution before writing my original post. But for relatively small projects such as mine, it seems overkill to depend on something as large as Babel just for installing message catalogues when distutils already does everything else I want to do, hence my original query. I've since added some code to my setup.py which adds a build_mo command and adds .mo installation to the install command. It'll probably need a bit more development for systems with which I'm not familiar but it's doing what I need for now. It still would be "killer" for this functionality to be handled in distutils. Regards, -- Andy Price
participants (4)
-
Andrew Price
-
Jeroen Ruigrok van der Werven
-
Philip Jenvey
-
Toshio Kuratomi