Search code examples
phpcgettext

How to get plural translation for string that requires context?


I know that the gettext library has pgettext() which can be used to translate a piece of string for given context. I also know that it has ngettext() which can be used to translate string which should have different singular and plurar forms.

How to translate a string which should have different singular and plurar forms and depends on context? It seems that logical extension called pngettext() doesn't exist.

I'd want to use such behavior from PHP but I'd be happy to know a solution for plain C only.


Solution

  • There seems to be npgettext() in Python's gettext documentation, and for C, a macro by that name is defined in gettext.h (but not libintl.h).