Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

gettext.gettext is imported as _:

from gettext import gettext as _

It's some naming convention, right? What's the equivalent for gettext.ngettext? __?

share|improve this question
up vote 2 down vote accepted

I've seen P_ (I assume the letter P stands for plural) used sometimes, but it seems there is not a general agreement or a defined standard for a shortcut to plural strings for translations in gettext.

Generally these shortcuts or macros are used in C and come from GLib, so they are not standard shortcuts from Gettext, but they've become a de facto standard for programs that use GLib. They are generally defined in the /usr/include/glib-2.0/glib/gi18n.h file, and explained in detail on the Internationalization API docs for GLib.

There are definitions for _ (gettext), Q_ (context), C_ (context), N_ (mark for translation only) and NC_ (mark for translation only, with context), but no P_

In any case, in Python you'll need to define the shortcuts yourself, but it'd be goot to stick to the same naming convention, for consistency's sake.

However, I seem to remember intltool does not recognize the P_ shortcut by default, so since ngettext is not used as often as gettext, you might want to just use the actual name of the function and not a shortcut.

If you still want to use a shortcut, and it is not supported by intltool, you'll need to tell intltool to use it, IIRC through the XGETTEXT variable or through the use of a Makevars file.

share|improve this answer
indeed, these strings were missing from the .pot file – int_ua Jul 5 '12 at 22:46
However, I like the idea to use __ (double underscore) for this... – int_ua Jul 5 '12 at 22:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.