Req #51285 [Opn->Wfx]: pgettext() and variants support for PHP
| From: | cmb@php.net | Date: | Mon, 25 Jan 2021 12:01:42 +0000 |
| Subject: | Req #51285 [Opn->Wfx]: pgettext() and variants support for PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231746@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
Updated by: cmb@php.net
Reported by: jani dot ollikainen at pronetko dot fi
Summary: pgettext() and variants support for PHP
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Gettext related
PHP Version: 5.3.2
-Assigned To:
+Assigned To: cmb
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).
This is why you should compare the return value of gettext() and
friends in the pgettext() wrappers. If it is identical to the
context, just return the message ID. That is exactly how
pgettext() and friends are implemented in GNU libintl.
I don't see the need to implement these functions in ext/gettext.
Previous Comments:
------------------------------------------------------------------------
[2014-08-28 07:39:10] PhoneixSegovia at gmail dot com
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);
}
------------------------------------------------------------------------
[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