Created
November 2, 2011 17:41
-
-
Save timonweb/1334321 to your computer and use it in GitHub Desktop.
Russian Plural Formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Plural form for Russian Language | |
* $form1 - singular value | |
* $form2 - double value | |
* $form3 - multiple value | |
*/ | |
function format_russian_plural($n, $form1, $form2, $form3) { | |
$n = abs($n) % 100; | |
$n1 = $n % 10; | |
if ($n > 10 && $n < 20) return $form3; | |
if ($n1 > 1 && $n1 < 5) return $form2; | |
if ($n1 == 1) return $form1; | |
return $form3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment