Skip to content

Commit

Permalink
upgrade cldr data to v41
Browse files Browse the repository at this point in the history
rename root locale references to und
  • Loading branch information
jrmajor committed Oct 17, 2022
1 parent 86f1be3 commit 2cc0f7a
Show file tree
Hide file tree
Showing 20 changed files with 158 additions and 147 deletions.
2 changes: 1 addition & 1 deletion dev/Helpers/CldrData.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function rules(): array
Type\dict(Type\string(), Type\string()),
)->assert($rules);

unset($rules['root']);
unset($rules['und']);

return $rules;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"dependencies": {
"cldr-core": "^39.0.0"
"cldr-core": "^41.0"
}
}
7 changes: 7 additions & 0 deletions rules/bal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use function Major\PluralRules\Operands\n;

return [
'one' => fn ($n) => n($n) == 1,
];
4 changes: 3 additions & 1 deletion rules/es.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use function Major\PluralRules\Operands\n;
use function Major\PluralRules\Operands\{e, i, n, v};
use function Major\PluralRules\Operators\{in_range, mod};

return [
'one' => fn ($n) => n($n) == 1,
'many' => fn ($n) => e($n) == 0 && i($n) != 0 && mod(i($n), 1000000) == 0 && v($n) == 0 || ! in_range(e($n), 0, 5),
];
File renamed without changes.
4 changes: 3 additions & 1 deletion rules/it.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use function Major\PluralRules\Operands\{i, v};
use function Major\PluralRules\Operands\{e, i, v};
use function Major\PluralRules\Operators\{in_range, mod};

return [
'one' => fn ($n) => i($n) == 1 && v($n) == 0,
'many' => fn ($n) => e($n) == 0 && i($n) != 0 && mod(i($n), 1000000) == 0 && v($n) == 0 || ! in_range(e($n), 0, 5),
];
10 changes: 0 additions & 10 deletions rules/iw.php

This file was deleted.

7 changes: 0 additions & 7 deletions rules/ji.php

This file was deleted.

4 changes: 3 additions & 1 deletion rules/pt-PT.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use function Major\PluralRules\Operands\{i, v};
use function Major\PluralRules\Operands\{e, i, v};
use function Major\PluralRules\Operators\{in_range, mod};

return [
'one' => fn ($n) => i($n) == 1 && v($n) == 0,
'many' => fn ($n) => e($n) == 0 && i($n) != 0 && mod(i($n), 1000000) == 0 && v($n) == 0 || ! in_range(e($n), 0, 5),
];
5 changes: 3 additions & 2 deletions rules/pt.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

use function Major\PluralRules\Operands\i;
use function Major\PluralRules\Operators\in_range;
use function Major\PluralRules\Operands\{e, i, v};
use function Major\PluralRules\Operators\{in_range, mod};

return [
'one' => fn ($n) => in_range(i($n), 0, 1),
'many' => fn ($n) => e($n) == 0 && i($n) != 0 && mod(i($n), 1000000) == 0 && v($n) == 0 || ! in_range(e($n), 0, 5),
];
3 changes: 3 additions & 0 deletions rules/tpi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return [];
14 changes: 10 additions & 4 deletions tests/Locale/JiTest.php → tests/Locale/BalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use Major\PluralRules\PluralRules;
use PHPUnit\Framework\TestCase;

final class JiTest extends TestCase
final class BalTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('ji', $num);
$category = PluralRules::select('bal', $num);
$this->assertSame('one', $category);
}

Expand All @@ -23,6 +23,10 @@ public function provideOneCases(): array
{
return [
[1],
[1.0],
['1.00'],
['1.000'],
['1.0000'],
];
}

Expand All @@ -31,7 +35,7 @@ public function provideOneCases(): array
*/
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('ji', $num);
$category = PluralRules::select('bal', $num);
$this->assertSame('other', $category);
}

Expand All @@ -50,7 +54,9 @@ public function provideOtherCases(): array
[100000],
[1000000],
[0.0],
[1.5],
[0.9],
[1.1],
[1.6],
[10.0],
[100.0],
[1000.0],
Expand Down
20 changes: 19 additions & 1 deletion tests/Locale/EsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ public function provideOneCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('es', $num);
$this->assertSame('many', $category);
}

/**
* @return list<array{int|float|string}>
*/
public function provideManyCases(): array
{
return [
[1000000],
];
}

/**
* @dataProvider provideOtherCases
*/
Expand All @@ -52,7 +71,6 @@ public function provideOtherCases(): array
[1000],
[10000],
[100000],
[1000000],
[0.0],
[0.9],
[1.1],
Expand Down
4 changes: 2 additions & 2 deletions tests/Locale/InTest.php → tests/Locale/HnjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use Major\PluralRules\PluralRules;
use PHPUnit\Framework\TestCase;

final class InTest extends TestCase
final class HnjTest extends TestCase
{
/**
* @dataProvider provideOtherCases
*/
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('in', $num);
$category = PluralRules::select('hnj', $num);
$this->assertSame('other', $category);
}

Expand Down
20 changes: 19 additions & 1 deletion tests/Locale/ItTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public function provideOneCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('it', $num);
$this->assertSame('many', $category);
}

/**
* @return list<array{int|float|string}>
*/
public function provideManyCases(): array
{
return [
[1000000],
];
}

/**
* @dataProvider provideOtherCases
*/
Expand All @@ -48,7 +67,6 @@ public function provideOtherCases(): array
[1000],
[10000],
[100000],
[1000000],
[0.0],
[1.5],
[10.0],
Expand Down
109 changes: 0 additions & 109 deletions tests/Locale/IwTest.php

This file was deleted.

20 changes: 19 additions & 1 deletion tests/Locale/PtPtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public function provideOneCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('pt-PT', $num);
$this->assertSame('many', $category);
}

/**
* @return list<array{int|float|string}>
*/
public function provideManyCases(): array
{
return [
[1000000],
];
}

/**
* @dataProvider provideOtherCases
*/
Expand All @@ -48,7 +67,6 @@ public function provideOtherCases(): array
[1000],
[10000],
[100000],
[1000000],
[0.0],
[1.5],
[10.0],
Expand Down

0 comments on commit 2cc0f7a

Please sign in to comment.