note 55365 added to function.ngettext
| From: | tfpsky-yahoocombr at osu1 dot php dot net | Date: | Mon, 01 Aug 2005 13:28:30 +0000 |
| Subject: | note 55365 added to function.ngettext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92867@lists.php.net to get a copy of this message | ||
You can use it to get plural translations:
in PO file (tranlation from en_US to pt_BR):
msgid "%d object"
msgid_plural "%d objects"
msgstr[0] "%d objeto"
msgstr[1] "%d objetos"
in you PHP, something like this:
<?php
$translationString = ngettext("%d object", "%d objects", $number);
printf( $translationString, $number );
?>
It will decide what to use, acording to $number: in this case, if $number == 1, ngettext returns the
first message ("%d object"). Else, it returns the second message ("%d objects").
Thanks to http://maconlinux.net/php-online-manual/en/function.ngettext.html
:D
Thiago F Pappacena
----
Submitter IP: 64.246.30.37
----
Manual Page -- http://www.php.net/manual/en/function.ngettext.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55365
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55365&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55365&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55365&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55365&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55365&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55365&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55365&report=yes
Search -- http://master.php.net/manage/user-notes.php