Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 1 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
add comment

Your Answer

 
discard

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.