Skip to content

Commit c6e1f75

Browse files
committed
Add German and Spanish
1 parent fb26a04 commit c6e1f75

5 files changed

Lines changed: 68 additions & 1 deletion

File tree

index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
const LANGUAGES = [
1313
'bg' => BulgarianLanguage::class,
14+
'de' => GermanLanguage::class,
15+
'es' => SpanishLanguage::class,
1416
'en' => EnglishLanguage::class,
1517
'ru' => RussianLanguage::class
16-
];
18+
];

src/GermanLanguage.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Oblik\Pluralization;
4+
5+
class GermanLanguage extends Language
6+
{
7+
use Rules\Cardinal1;
8+
9+
static function ordinal($n)
10+
{
11+
return OTHER;
12+
}
13+
14+
const RANGE = [
15+
ONE . OTHER => OTHER,
16+
OTHER . ONE => ONE,
17+
OTHER . OTHER => OTHER
18+
];
19+
}

src/SpanishLanguage.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
namespace Oblik\Pluralization;
4+
5+
class SpanishLanguage extends BulgarianLanguage
6+
{ }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Oblik\Pluralization;
4+
5+
final class GermanLanguageTest extends LanguageTestCase
6+
{
7+
static $class = GermanLanguage::class;
8+
9+
public function testCardinals()
10+
{
11+
$this->checkCardinals(ONE, [1]);
12+
$this->checkCardinals(OTHER, [0, [2, 16], 100, 1000, 10000]);
13+
$this->checkCardinals(OTHER, [[0, 1.5, 1], '10.0', '100.0', '1000.0', '10000.0']);
14+
}
15+
16+
public function testOrdinals()
17+
{
18+
$this->checkOrdinals(OTHER, [[0, 15], 100, 1000]);
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Oblik\Pluralization;
4+
5+
final class SpanishLanguageTest extends LanguageTestCase
6+
{
7+
static $class = SpanishLanguage::class;
8+
9+
public function testCardinals()
10+
{
11+
$this->checkCardinals(ONE, [1, '1.0', '1.00', '1.000']);
12+
$this->checkCardinals(OTHER, [0, [2, 16], 100, 1000, 10000]);
13+
$this->checkCardinals(OTHER, [[0, 0.9, 1], [1.1, 1.6, 1], '10.0', '100.0', '1000.0', '10000.0']);
14+
}
15+
16+
public function testOrdinals()
17+
{
18+
$this->checkOrdinals(OTHER, [[0, 15], 100, 1000]);
19+
}
20+
}

0 commit comments

Comments
 (0)