Req #51285 [Com]: pgettext() and variants support for PHP

From: Date: Thu, 28 Aug 2014 07:39:11 +0000
Subject: Req #51285 [Com]: pgettext() and variants support for PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187309@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=51285&edit=1 ID: 51285 Comment by: PhoneixSegovia at gmail dot com Reported by: jani dot ollikainen at pronetko dot fi Summary: pgettext() and variants support for PHP Status: Open Type: Feature/Change Request Package: Gettext related PHP Version: 5.3.2 Block user comment: N Private report: N New Comment: The problem with user implementations is that when a translation isn't found, the cryptic message is returned (the union of context and message). And this why in gettext you use the message as identifier (among other things). To give full support to gettext, pgettext variant must be implemented, and is an important flag if not implemented, why gettext implemented it if not? Also, I think that n.oxyde definition of function pgettext($context, $message) { return gettext($actual_message); } Must really be: function pgettext($context, $message) { $actual_message = $context . "\04" . $message; return gettext($actual_message); } Previous Comments: ------------------------------------------------------------------------ [2012-04-12 12:26:53] n dot oxyde at gmail dot com You don't need builtin support of pcontext() functions to use Gettext contexts. 1/ Define the functions yourself: function pgettext($context, $message) { return gettext($actual_message); } function dpgettext($domain, $context, $message) { $actual_message = $context . "\04" . $message; return dgettext($domain, $actual_message); } function dcpgettext($domain, $context, $message, $category) { $actual_message = $context . "\04" . $message; return dcgettext($domain, $actual_message, $category); } function npgettext($context, $msgid1, $msgid2, $n) { $actual_msgid1 = $context . "\04" . $msgid1; $actual_msgid2 = $context . "\04" . $msgid2; return ngettext($actual_msgid1, $actual_msgid2, $n); } function dnpgettext($domain, $context, $msgid1, $msgid2, $n) { $actual_msgid1 = $context . "\04" . $msgid1; $actual_msgid2 = $context . "\04" . $msgid2; return dngettext($domain, $actual_msgid1, $actual_msgid2, $n); } function dcnpgettext( $domain, $context, $msgid1, $msgid2, $n, $category) { $actual_msgid1 = $context . "\04" . $msgid1; $actual_msgid2 = $context . "\04" . $msgid2; return dcngettext( $domain, $actual_msgid1, $actual_msgid2, $n, $category); } 2/ Pass additional keywords arguments to xgettext: xgettext \ -kpgettext:1c,2 \ -kdpgettext:2c,3 \ -kdcpgettext:2c,3 \ -knpgettext:1c,2,3 \ -kdnpgettext:2c,3,4 \ -kdcnpgettext:2c,3,4 ------------------------------------------------------------------------ [2010-03-12 14:56:28] jani dot ollikainen at pronetko dot fi Description: ------------ Newer gettext libraries provide Contexts to translate words that could be need context based translation in other languages. http://www.gnu.org/software/gettext/manual/gettext.html#Contexts PHP's gettext library doesn't support those. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=51285&edit=1

« previous php.bugs (#187309) next »