forked from OblikStudio/php-pluralization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLithuanianLanguage.php
48 lines (43 loc) · 1.15 KB
/
LithuanianLanguage.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
<?php
namespace Oblik\Pluralization;
class LithuanianLanguage extends Language
{
static function cardinal(float $n, int $i, int $v, int $w, int $f, int $t)
{
$mod10 = $n % 10;
$mod100 = $n % 100;
$hasNonZeroDecimal = $n != $i;
if (!$hasNonZeroDecimal && $mod10 == 1 && !self::inRange($mod100, [11, 19])) {
return ONE;
}
elseif (!$hasNonZeroDecimal && self::inRange($mod10, [2, 19]) && !self::inRange($mod100, [11, 19])) {
return FEW;
}
elseif ($f != 0) {
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,
];
}