views:

105

answers:

1

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/

+1  A: 

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 ....

Denis Otkidach
Hi Denis: Thank you for your help. I'm aware of the -k option, but can't find a way to map N_ or n_ to the ngettext function so that these function's parameters get processed as plurals (creating msgid_plural, msgid[0], etc) vs. an alias of gettext. I appreciate the reference to the use of N_ as a NULL translation. This seems like a Python specific syntax (?) as opposed to other language gettext implementations which support N_ or n_ as ngettext aliases.
Malcolm
Hi Denis: Your "-k n_:1,2" technique works perfectly - thank you very much!! For the archives: We've decided to use N_ vs. n_ to follow what look likes the defacto industry standard for ngettext abbreviation.
Malcolm