9
votes

We're evaluating Babel 0.9.5 [1] under Windows for use with Python 2.6 and have the following questions that we we've been unable to answer through reading the documentation or googling.

1) I would like to use an _ like abbreviation for ungettext. Is there a concencus on whether one should use n_ or N_ for this?

n_ does not appear to work. Babel does not extract text.

N_ appears to partially work. Babel extracts text like it does for gettext, but does not format for ngettext (missing plural argument and msgstr[ n ].)

2) Is there a way to set the initial msgstr fields like the following when creating a POT file?

I suspect there may be a way to do this via Babel cfg files, but I've been unable to find documentation on the Babel cfg file format.

"Project-Id-Version: PROJECT VERSION\n" "Language-Team: en_US \n"

3) Is there a way to preserve 'obsolete' msgid/msgstr's in our PO files? When I use the Babel update command, newly created obsolete strings are marked with #~ prefixes, but existing obsolete message strings get deleted.

Thanks, Malcolm

[1] http://babel.edgewall.org/

2
Why you don't want to use just GNU gettext utilities ported to win32 for extracting the messages? gnuwin32.sf.netbialix
Hi Bializ: Installing the GNU gettext utlities is not convenient for our customers who maintain their own PO files. Another advantage of the Babel utilities is that they work in UTF-8 mode by default. We've had some problems getting the GNU gettext utilities to do this consistently (they default to ASCIII).Malcolm

2 Answers

8
votes

By default pybabel extract recognizes the following keywords: _, gettext, ngettext, ugettext, ungettext, dgettext, dngettext,N_. Use -k option to add others. N_ is often used for NULL-translations (also called deferred translations).

Update: The -k option can list arguments of function to be put in catalog. So, if you use n_ = ngettext try pybabel extract -k n_:1,2 ....

1
votes

To answer question 2):

If you run Babel via pybabel extract, you can set Project-Id-Version via the --project and --version options.

If you run Babel via setup.py extract_messages, then Project-Id-Version is taken from the distribution (project name and version in the setup.py file).

Both ways also support the options --msgid-bugs-address and --copyright-holder for setting the POT metadata.