[I18n-sig] pygettext dilemma

Barry A. Warsaw barry@zope.com
Fri, 27 Jul 2001 01:32:43 -0400

I've got a bit of a dilemma about the right way to generate a pot
file, specifically for Mailman.  Because this involves docstrings, I
don't think the normal gettext tools have to deal with this.

In Mailman, I've got a bunch of normal .py modules and a bunch of
command line scripts.  The modules have their translatable strings
nicely marked with _() and only those strings should be extracted.
The scripts however should have both _() and docstrings extracted,
since the module docstrings include usage text.

pygettext.py has a -D (--docstrings) flag that signals the program to
extract docstrings even though they aren't _() marked.  So far so

But the problem is that my translators definitely do not want
the normal .py modules' docstrings extracted, because it is difficult
for them to figure out which docstrings to translate and which to
ignore.  I tried to extract the two classes of files in two separate
pygettext.py steps, but had trouble merging the resulting files.  You
can't merge them with msgmerge because that program seems to just drop
all the entries from the second file (I'm guessing since there's no
overlap between the first and second files).

So next I tried just cat'ing the two files together, but this
generates fatal exceptions in msgmerge for duplicate entries.  One of
the duplicates is the pot header, so I was going to add a switch to
suppress that, but then realized that there'd be other duplicates

What I /think/ I want now is to be able to tell pygettext.py exactly
which files to extract docstrings from and which to only extract
marked strings from, and then do the extraction in one fell swoop.

I propose to include a -X flag like so:

    -X filename
        Specify a file that contains a list of files that should not have
        their docstrings extracted.  This is only useful in conjunction with
        the -D option above.

So with this I'd hand pygettext.py the entire list of files that it
should do extraction on, include the -D option, and then include the
-X option with the normal module .py's listed in an exclude-file.

Does anybody have any suggestions or better ideas?