forked from OblikStudio/php-pluralization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRussianLanguage.php
55 lines (49 loc) · 1.24 KB
/
RussianLanguage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Oblik\Pluralization;
class RussianLanguage extends Language
{
static function cardinal(float $n, int $i, int $v)
{
$mod10 = $i % 10;
$mod100 = $i % 100;
if ($v === 0) {
if ($mod10 == 1 && $mod100 != 11) {
return ONE;
} elseif (
self::inRange($mod10, [2, 4]) &&
!self::inRange($mod100, [12, 14])
) {
return FEW;
} elseif (
$mod10 == 0 ||
self::inRange($mod10, [5, 9]) ||
self::inRange($mod100, [11, 14])
) {
return MANY;
}
}
return OTHER;
}
static function ordinal(int $n)
{
return OTHER;
}
const RANGE = [
ONE . ONE => ONE,
ONE . FEW => FEW,
ONE . MANY => MANY,
ONE . OTHER => OTHER,
FEW . ONE => ONE,
FEW . FEW => FEW,
FEW . MANY => MANY,
FEW . OTHER => OTHER,
MANY . ONE => ONE,
MANY . FEW => FEW,
MANY . MANY => MANY,
MANY . OTHER => OTHER,
OTHER . ONE => ONE,
OTHER . FEW => FEW,
OTHER . MANY => MANY,
OTHER . OTHER => OTHER,
];
}