Gettext translate with grammatical case

Zend 3. I’m using gettext translator with some locales. By defaut I use en locale without specific .po file. How I can translate with grammatical case, I try to use: $this->translate("genitive" . "translate_text") and this works with languages, that have .po file, but for english locale (without .po file) I have "genitivetranslate_text" in result. How should I to use translate method with grammatical case to get the correct result?
For example, in wordpress it looks like this: _x("January", "genitive") (grammatical case by second argument)

It can be used for much more than a “grammatical case”. Therefore it is called “context”.


It works, because the entire string is used as “message identifier” and if a translation file (.po file) contains this message, then you will get the translated text.

This also correct, because:

When there is no translation for a specific message identifier in a locale, the message identifier itself will be returned by default.

The translator of zend-i18n currently ships with support of 3 translation formats (PHP arrays [file and memory], Gettext, INI) and provides unified access for these formats. But only Gettext supports the context feature and so you will not find an option for that in the unified access and the related helpers.

To solve your problem you can:

Btw. PHP itself does not support the context feature of Gettext.

Search for “pgettext”:

Thanks for your the answer. I also thought about the English .po file, but this is a duplicate of the common translation list. Probably I’ll try to expand the base class of the translator.