note 93015 added to function.ngettext
| From: | hek at theeks dot net | Date: | Wed, 19 Aug 2009 18:07:44 +0000 |
| Subject: | note 93015 added to function.ngettext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159647@lists.php.net to get a copy of this message | ||
Beware of one difference between the GNU gettext API and the PHP binding of it, which is that the
GNU gettext functions that accept a $count parameter all expect (indeed, being compiled C, require)
that $count be unsigned, while the PHP binding does not.
Thus, the PHP gettext functions will happily accept negative numbers. The one potentially irritating
consequence of this is that -1 is treated as plural, which sits well with some people and not so
well with others. (As a picky native speaker of English, my personal opinion is that both "the
temperature is minus one degree Fahrenheit" and "four apples minus five apples leaves
minus one apple" but others may feel that "four apples minus five apples leaves minus one
apples" sounds better.)
The upshot: You may want to abs($count) before passing numbers to gettext.
Bonus points: If your application includes user preferences, you might offer a "treat -1 as
singular" option to your users, then choose $count or abs($count) to pass to gettext based on
each user's preference.
----
Server IP: 208.69.120.35
Probable Submitter: 208.89.176.36
----
Manual Page -- http://www.php.net/manual/en/function.ngettext.php
Edit -- https://master.php.net/note/edit/93015
Del: integrated -- https://master.php.net/note/delete/93015/integrated
Del: useless -- https://master.php.net/note/delete/93015/useless
Del: bad code -- https://master.php.net/note/delete/93015/bad+code
Del: spam -- https://master.php.net/note/delete/93015/spam
Del: non-english -- https://master.php.net/note/delete/93015/non-english
Del: in docs -- https://master.php.net/note/delete/93015/in+docs
Del: other reasons-- https://master.php.net/note/delete/93015
Reject -- https://master.php.net/note/reject/93015
Search -- https://master.php.net/manage/user-notes.php