-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nikitos-mv/master
New languages & some fixes
- Loading branch information
Showing
79 changed files
with
2,035 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Oblik\Pluralization; | ||
|
||
class AlbanianLanguage extends Language | ||
{ | ||
static function cardinal(float $n) | ||
{ | ||
if ($n == 1) { | ||
return ONE; | ||
} | ||
return OTHER; | ||
} | ||
|
||
static function ordinal(int $n) | ||
{ | ||
if ($n == 1) | ||
{ | ||
return ONE; | ||
} | ||
elseif ($n % 10 == 4 && $n % 100 != 14) | ||
{ | ||
return MANY; | ||
} | ||
return OTHER; | ||
} | ||
|
||
const RANGE = [ | ||
ONE . OTHER => OTHER, | ||
OTHER . ONE => ONE, | ||
OTHER . OTHER => OTHER | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Oblik\Pluralization; | ||
|
||
class AmharicLanguage extends Language | ||
{ | ||
static function cardinal(float $n) | ||
{ | ||
if ($n == 0 || $n == 1) { | ||
return ONE; | ||
} | ||
return OTHER; | ||
} | ||
|
||
static function ordinal() | ||
{ | ||
return OTHER; | ||
} | ||
|
||
const RANGE = [ | ||
ONE . ONE => ONE, | ||
ONE . OTHER => OTHER, | ||
OTHER . OTHER => OTHER, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
namespace Oblik\Pluralization; | ||
|
||
class BelarusianLanguage extends RussianLanguage | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Oblik\Pluralization; | ||
|
||
class BengaliLanguage extends Language | ||
{ | ||
static function cardinal(float $n, int $i) | ||
{ | ||
if ($i == 0 || $n == 1) { | ||
return ONE; | ||
} | ||
return OTHER; | ||
} | ||
|
||
static function ordinal(int $n) | ||
{ | ||
if ($n == 1 || $n == 5 || ($n >= 7 && $n <= 10)) { | ||
return ONE; | ||
} | ||
elseif ($n == 2 || $n == 3) { | ||
return TWO; | ||
} | ||
elseif ($n == 4) { | ||
return FEW; | ||
} | ||
elseif ($n == 6) { | ||
return MANY; | ||
} | ||
return OTHER; | ||
} | ||
|
||
const RANGE = [ | ||
ONE . ONE => ONE, | ||
ONE . OTHER => OTHER, | ||
OTHER . OTHER => OTHER, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Oblik\Pluralization; | ||
|
||
class BosnianLanguage extends Language | ||
{ | ||
static function cardinal(float $n, int $i, int $v, int $w, int $f) | ||
{ | ||
$imod10 = $i % 10; | ||
$imod100 = $i % 100; | ||
$fmod10 = $f % 10; | ||
$fmod100 = $f % 100; | ||
|
||
if ( | ||
($v == 0 && $imod10 == 1 && $imod100 != 11) | ||
|| ($fmod10 == 1 && $fmod100 != 11) | ||
) { | ||
return ONE; | ||
} | ||
elseif ( | ||
($v == 0 && self::inRange($imod10, [2, 4]) && !self::inRange($imod100, [12, 14])) | ||
|| (self::inRange($fmod10, [2, 4]) && !self::inRange($fmod100, [12, 14])) | ||
) { | ||
return FEW; | ||
} | ||
return OTHER; | ||
} | ||
|
||
static function ordinal(int $n) | ||
{ | ||
return OTHER; | ||
} | ||
|
||
const RANGE = [ | ||
ONE . ONE => ONE, | ||
ONE . FEW => FEW, | ||
ONE . OTHER => OTHER, | ||
FEW . ONE => ONE, | ||
FEW . FEW => FEW, | ||
FEW . OTHER => OTHER, | ||
OTHER . ONE => ONE, | ||
OTHER . FEW => FEW, | ||
OTHER . OTHER => OTHER, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Oblik\Pluralization; | ||
|
||
class CatalanLanguage extends Language | ||
{ | ||
static function cardinal(float $n, int $i, int $v) | ||
{ | ||
if ($i == 1 && $v == 0) { | ||
return ONE; | ||
} | ||
return OTHER; | ||
} | ||
|
||
static function ordinal(int $n) | ||
{ | ||
if ($n == 1 || $n == 3) | ||
{ | ||
return ONE; | ||
} | ||
elseif ($n == 2) | ||
{ | ||
return TWO; | ||
} | ||
elseif ($n == 4) | ||
{ | ||
return FEW; | ||
} | ||
return OTHER; | ||
} | ||
|
||
const RANGE = [ | ||
ONE . OTHER => OTHER, | ||
OTHER . ONE => OTHER, | ||
OTHER . OTHER => OTHER | ||
]; | ||
} |
Oops, something went wrong.