[XML-SIG] Will gettext do?

Martin v. Loewis martin@mira.cs.tu-berlin.de
Wed, 31 Jan 2001 00:30:17 +0100


> Here is the procedure I follow in distutils, say for 4DOM.
> 
> 1. run pygettext to create build/[platform]/_xmlplus/4Suite.po
> 2. run msgfmt to create the build/[platform]/_xmlplus/4Suite.mo
> 3. create build/[platform]/_xmlplus/en_US/LC_MESSAGES and move 4Suite.mo there
> 4. Make distutils copy build/[platform]/_xmlplus/en_US/LC_MESSAGES/4Suite.mo 
> to the equivalent directory in the Python lib
> 
> The problem is step 3.  I can't see a way (and I read all the way through 
> msgfmt.py) to automatically mark the locales whose directories I should 
> create.  I basically hard-code the creation of "en_US", and I'd have to 
> hard-code "de_DE" and all that when I get the translations.
> 
> Maybe this is how it's supposed to be, but it seems odd.
> 
> I'll troll about a bit more in Tools/i18n/, but I thought maybe Martin or 
> someone has the snap answer.

It's my turn to go to bed now :-) but as a snap answer: the common
tradition is to have 4Suite.<lang>.po in the source distribution,
where <lang> is typically fr, de, en (and *not* fr_FR, de_DE, en_US -
unless the German translation for Germany really differs from the one
for, say, Austria). With that, it should not be too difficult to
generate the directories in a loop.

Furthermore, I feel that any <package/<lang>/LC_MESSAGES/catalog.po
approach is bad (even though it's gettext tradition), so I'd promote
the idea of having <package>.<lang>.mo instead, and keeping the mo
files all in a single directory. Unfortunately, I'm not sure whether
gettext.py supports such a scheme - essentially, you need the module
to tell you what languages to consider in what order, but you may want
to override the resulting file naming scheme.

So *if* you can install into <python prefix>/share/locale, that is
probably best if that also is the platform convention, otherwise, any
scheme that just works should do - even if it creates many extra
directories.

I'd support proposals to enhance gettext.py for easier distribution of
catalogs - in particular on non-Unix platforms, as well as proposals
to enhance distutils to support message catalogs.

Regards,
Martin