<?php
// locale: ??????? (Russia) (ru_RU)
// author: Oleg Bogdanov https://github.com/wormen
/**
* returns ending for plural form of word by number and array of variants (1, 4, 5)
* example variants for apples ['??????', '??????', '?????']
*/
/**
* @param int $number
* @param array $endingArray
*
* @return string
*/
$getNumEnding = function ($number, array $endingArray)
{
$number = $number % 100;
if ($number >= 11 && $number <= 19)
{
return $endingArray[2];
}
$i = $number % 10;
switch ($i)
{
case (1):
$ending = $endingArray[0];
break;
case (2):
case (3):
case (4):
$ending = $endingArray[1];
break;
default:
$ending = $endingArray[2];
}
return $ending;
};
return array(
'months' => explode('_', '??????_???????_?????_??????_???_????_????_???????_????????_???????_??????_???????'),
'monthsNominative' => explode('_', '??????_???????_????_??????_???_????_????_??????_????????_???????_??????_???????'),
'monthsShort' => explode('_', '???_???_???_???_???_???_???_???_???_???_???_???'),
'weekdays' => explode('_', '???????????_???????_?????_???????_???????_???????_???????????'),
'weekdaysShort' => explode('_', '??_??_??_??_??_??_??'),
'calendar' => array(
'sameDay' => '[???????]',
'nextDay' => '[??????]',
'lastDay' => '[?????]',
'lastWeek' => 'l',
'sameElse' => 'l',
'withTime' => '[?] H:i',
'default' => 'd/m/Y',
),
'relativeTime' => array(
'future' => '????? %s',
'past' => '%s ?????',
's' => '????????? ??????',
'ss' => function ($number) use ($getNumEnding)
{
return $getNumEnding($number, array('%d ???????', '%d ???????', '%d ??????'));
},
'm' => '??????',
'mm' => function ($number) use ($getNumEnding)
{
return $getNumEnding($number, array('%d ??????', '%d ??????', '%d ?????'));
},
'h' => '???',
'hh' => function ($number) use ($getNumEnding)
{
return $getNumEnding($number, array('%d ???', '%d ????', '%d ?????'));
},
'd' => '????',
'dd' => function ($number) use ($getNumEnding)
{
return $getNumEnding($number, array('%d ????', '%d ???', '%d ????'));
},
'M' => '?????',
'MM' => function ($number) use ($getNumEnding)
{
return $getNumEnding($number, array('%d ?????', '%d ??????', '%d ???????'));
},
'y' => '???',
'yy' => function ($number) use ($getNumEnding)
{
return $getNumEnding($number, array('%d ???', '%d ????', '%d ???'));
},
),
'ordinal' => function ($number)
{
return $number . '?';
},
'week' => array(
'dow' => 1, // Monday is the first day of the week.
'doy' => 4 // The week that contains Jan 4th is the first week of the year.
),
);
|