note 60878 deleted from function.gettext by danbrown
| From: | danbrown@php.net | Date: | Tue, 08 Sep 2009 22:30:17 +0000 |
| Subject: | note 60878 deleted from function.gettext by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160335@lists.php.net to get a copy of this message | ||
Note Submitter: daevid at daevid dot com
----
It appears that this version of gettext() is lame and doesn't support [_1] and [_2] ...
modifier/parameters.
Here is a little hack around this:
<?php
function translate($string)
{
$arg = array();
for($i = 1 ; $i < func_num_args(); $i++)
$arg[] = func_get_arg($i);
return vsprintf(gettext($string), $arg);
}
$foo = 'Foo';
print translate("Found %1\$s Devices on Range %2\$s", "20",
$foo)."<P>\n";
?>
To clarify, you'd put this string in your .po file:
"Found %1\$s Devices on Range %2\$s"