note 80382 added to function.ngettext

From: Date: Sun, 13 Jan 2008 08:51:48 +0000
Subject: note 80382 added to function.ngettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-135064@lists.php.net to get a copy of this message
Another ready to use function for russian plural implementation: <?php function plural_str ($i, $str1, $str2, $str3){ function plural ($a){ if ($a%10==1 && $a%100!=11){ return 0; } elseif($a%10>=2 && $a%10<=4 && ($a%100<10 || $a%100>=20)) { return 1; } else { return 2; } } $plural= plural ($i); switch ($plural) { case 0: $out_str = $str1; break; case 1: $out_str = $str2; break; default: $out_str = $str3; } return $out_str; } //// Usage: $n = 3; echo $n .' '. plural_str($n, 'тетрадь', 'тетради', 'тетрадей'); //// Output: '3 тетради' ?> ---- Server IP: 91.196.196.241 Probable Submitter: 77.109.39.28 ---- Manual Page -- http://www.php.net/manual/en/function.ngettext.php Edit -- https://master.php.net/note/edit/80382 Del: integrated -- https://master.php.net/note/delete/80382/integrated Del: useless -- https://master.php.net/note/delete/80382/useless Del: bad code -- https://master.php.net/note/delete/80382/bad+code Del: spam -- https://master.php.net/note/delete/80382/spam Del: non-english -- https://master.php.net/note/delete/80382/non-english Del: in docs -- https://master.php.net/note/delete/80382/in+docs Del: other reasons-- https://master.php.net/note/delete/80382 Reject -- https://master.php.net/note/reject/80382 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135064) next »