note 60878 added to function.gettext

From: Date: Thu, 19 Jan 2006 03:51:16 +0000
Subject: note 60878 added to function.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-102072@lists.php.net to get a copy of this message
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" ---- Server IP: 64.246.30.37Probable Submitter: 67.105.193.226 ---- Manual Page -- http://www.php.net/manual/en/function.gettext.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60878 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60878&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60878&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102072) next »