1

gettext.gettext is imported as _:

from gettext import gettext as _

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

int_ua
  • 8,892

1 Answers1

2

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.