Skip to content

Instantly share code, notes, and snippets.

@timonweb
Created November 2, 2011 17:41
Show Gist options
  • Save timonweb/1334321 to your computer and use it in GitHub Desktop.
Save timonweb/1334321 to your computer and use it in GitHub Desktop.
Russian Plural Formatter
/**
* 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