private static $plurals = array(
'goods' => array('товар', 'товара', 'товаров'),
);
private static function pluralType($n)
{
return ($n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2));
}
public static function getPlural($key, $count)
{
return static::$plurals[$key][static::pluralType($count)];
}
echo Поиск среди {{ $count }} {{ Pluralizer::getPlural('goods', $count) }}
private static function pluralType($n)
{
return $n != 11 && $n % 10 == 1 ? 0 : 1;
}
function ending($number, $one, $two, $five)
{
$number = $number % 100;
if ( ($number > 4 && $number < 21) || $number == 0 )
{
$ending = $five;
}
else
{
$last_digit = substr($number, -1);
if ( $last_digit > 1 && $last_digit < 5 )
$ending = $two;
elseif ( $last_digit == 1 )
$ending = $one;
else
$ending = $five;
}
return $ending;
}
'Товар' . ending($number, '', 'а', 'ов')
ending($years, 'год', 'года', 'лет')
if ($count%10==1) $simv='символ';
else if ($count%10==2 or $count%10==3 or $count%10==4) $count='символа';
else $simv='символов';
if ($count%10==1) $simv='товара';
else $count='товаров';