Skip to content

Commit 4411077

Browse files
authored
Merge pull request #33 from MichaelHoste/master
Update CLDR data from 36 to 39
2 parents 5473976 + 3cd0e6e commit 4411077

9 files changed

Lines changed: 55 additions & 30 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ jobs:
6363
- name: Checkout
6464
uses: actions/checkout@v2
6565
- name: Install Composer dependencies
66-
run: composer update --no-progress --no-suggest --optimize-autoloader --no-ansi --no-interaction
66+
run: composer update --no-progress --no-suggest --optimize-autoloader --ansi --no-interaction
6767
- name: Run PHPUnit
6868
run: composer --no-interaction run-script test

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ To use the languages data generated from this tool you can use the `bin/export-p
88

99
#### Export command line options
1010
`export-plural-rules` supports the following options:
11-
- `--us-ascii`
11+
- `--us-ascii`
1212
If specified, the output will contain only US-ASCII characters.
1313
If not specified, the output charset is UTF-8.
14-
- `--languages=<LanguageId>[,<LanguageId>,...]]`
15-
`--language=<LanguageId>[,<LanguageId>,...]]`
14+
- `--languages=<LanguageId>[,<LanguageId>,...]]`
15+
`--language=<LanguageId>[,<LanguageId>,...]]`
1616
Export only the specified language codes.
1717
Separate languages with commas; you can also use this argument more than once; it's case insensitive and accepts both '_' and '-' as locale chunks separator (eg we accept `it_IT` as well as `it-it`).
1818
If this option is not specified, the result will contain all the available languages.
19-
- `--reduce=yes|no`
19+
- `--reduce=yes|no`
2020
If set to yes the output won't contain languages with the same base language and rules.
2121
For instance `nl_BE` (`Flemish`) will be omitted because it's the same as `nl` (`Dutch`).
2222
Defaults to `no` if `--languages` is specified, to `yes` otherwise.
23-
- `--parenthesis=yes|no`
23+
- `--parenthesis=yes|no`
2424
If set to no, extra parenthesis will be omitted in generated plural rules formulas.
2525
Those extra parenthesis are needed to create a PHP-compatible formula.
2626
Defaults to `yes`
27-
- `--output=<file name>`
27+
- `--output=<file name>`
2828
If specified, the output will be saved to `<file name>`. If not specified we'll output to standard output.
2929

3030
#### Export formats
@@ -90,14 +90,14 @@ $oneLanguage = Gettext\Languages\Language::getById('en_US');
9090
The main properties of the `Gettext\Languages\Language` instances are:
9191
- `id`: the normalized language ID (for instance `en_US`)
9292
- `name`: the language name (for instance `American English` for `en_US`)
93-
- `supersededBy`: the code of a language that supersedes this language code (for instance, `jw` is superseded by `jv` to represent the Javanese language)
93+
- `supersededBy`: the code of a language that supersedes this language code (for instance, `jw` is superseded by `jv` to represent the Javanese language)
9494
- `script`: the script name (for instance, for `zh_Hans` - `Simplified Chinese` - the script is `Simplified Han`)
9595
- `territory`: the name of the territory (for instance `United States` for `en_US`)
9696
- `baseLanguage`: the name of the base language (for instance `English` for `en_US`)
97-
- `formula`: the [gettext formula](https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Plural-forms.html) to distinguish between different plural rules. For instance `n != 1`
97+
- `formula`: the [gettext formula](https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Plural-forms.html) to distinguish between different plural rules. For instance `n != 1`
9898
- `categories`: the plural cases applicable for this language. It's an array of `Gettext\Languages\Category` instances. Each instance has these properties:
9999
- `id`: can be (in this order) one of `zero`, `one`, `two`, `few`, `many` or `other`. The `other` case is always present.
100-
- `examples`: a representation of some values for which this plural case is valid (examples are simple numbers like `1` or complex ranges like `0, 2~16, 100, 1000, 10000, 100000, 1000000, …`)
100+
- `examples`: a representation of some values for which this plural case is valid (examples are simple numbers like `1` or complex ranges like `0, 2~16, 100, 1000, 10000, 100000, 1000000, …`)
101101

102102

103103
## Is this data correct?
@@ -120,6 +120,8 @@ The [CLDR specifications](https://unicode.org/reports/tr35/tr35-numbers.html#Lan
120120
- `w`: number of visible fraction digits in n, without trailing zeros (eg: `9.870` => `2`)
121121
- `f`: visible fractional digits in n, with trailing zeros (eg: `9.870` => `870`)
122122
- `t`: visible fractional digits in n, without trailing zeros (eg: `9.870` => `87`)
123+
- `c`: exponent of the power of 10 used in compact decimal formatting (eg: `98c7` => `7`)
124+
- `e`: synonym for `c`
123125

124126
#### gettext
125127

@@ -136,6 +138,8 @@ The [gettext specifications](https://www.gnu.org/savannah-checkouts/gnu/gettext/
136138
| `w` | `0` |
137139
| `f` | *empty* |
138140
| `t` | *empty* |
141+
| `c` | *empty* |
142+
| `e` | *empty* |
139143

140144

141145

src/Category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public static function expandExamples($examples)
100100
$examples = substr($examples, 0, strlen($examples) - strlen(', …'));
101101
}
102102
foreach (explode(',', str_replace(' ', '', $examples)) as $range) {
103-
if (preg_match('/^\d+$/', $range)) {
104-
$result[] = (int) $range;
103+
if (preg_match('/^(?<num>\d+)((c|e)(?<exp>\d+))?$/', $range, $m)) {
104+
$result[] = (int) (isset($m['exp']) ? ($m['num'] . str_repeat('0', (int) $m['exp'])) : $range);
105105
} elseif (preg_match('/^(\d+)~(\d+)$/', $range, $m)) {
106106
$from = (int) $m[1];
107107
$to = (int) $m[2];

src/FormulaConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ private static function convertAtom($cldrAtom)
9595
if (preg_match('/^(?:v|w)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // For gettext: v == 0, w == 0
9696
return (int) $m[1] === 0 ? false : true;
9797
}
98-
if (preg_match('/^(?:f|t)(?: % 10+)? == (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // f == empty, t == empty
98+
if (preg_match('/^(?:f|t|c|e)(?: % 10+)? == (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // f == empty, t == empty, c == empty, e == empty
9999
return (int) $m[1] === 0 ? true : false;
100100
}
101-
if (preg_match('/^(?:f|t)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // f == empty, t == empty
101+
if (preg_match('/^(?:f|t|c|e)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // f == empty, t == empty, c == empty, e == empty
102102
return (int) $m[1] === 0 ? false : true;
103103
}
104104
throw new Exception("Unable to convert the formula chunk '{$cldrAtom}' from CLDR to gettext");

src/cldr-data/main/en-US/languages.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"en-US": {
44
"identity": {
55
"version": {
6-
"_number": "$Revision$",
7-
"_cldrVersion": "36"
6+
"_cldrVersion": "39"
87
},
98
"language": "en",
109
"territory": "US"
@@ -41,6 +40,7 @@
4140
"arp": "Arapaho",
4241
"arq": "Algerian Arabic",
4342
"ars": "Najdi Arabic",
43+
"ars-alt-menu": "Arabic, Najdi",
4444
"arw": "Arawak",
4545
"ary": "Moroccan Arabic",
4646
"arz": "Egyptian Arabic",
@@ -115,6 +115,8 @@
115115
"chy": "Cheyenne",
116116
"cic": "Chickasaw",
117117
"ckb": "Central Kurdish",
118+
"ckb-alt-menu": "Kurdish, Central",
119+
"ckb-alt-variant": "Kurdish, Sorani",
118120
"co": "Corsican",
119121
"cop": "Coptic",
120122
"cps": "Capiznon",
@@ -474,7 +476,6 @@
474476
"ro-MD": "Moldavian",
475477
"rof": "Rombo",
476478
"rom": "Romany",
477-
"root": "Root",
478479
"rtm": "Rotuman",
479480
"ru": "Russian",
480481
"rue": "Rusyn",

src/cldr-data/main/en-US/scripts.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"en-US": {
44
"identity": {
55
"version": {
6-
"_number": "$Revision$",
7-
"_cldrVersion": "36"
6+
"_cldrVersion": "39"
87
},
98
"language": "en",
109
"territory": "US"
@@ -17,6 +16,7 @@
1716
"Ahom": "Ahom",
1817
"Arab": "Arabic",
1918
"Arab-alt-variant": "Perso-Arabic",
19+
"Aran": "Nastaliq",
2020
"Armi": "Imperial Aramaic",
2121
"Armn": "Armenian",
2222
"Avst": "Avestan",
@@ -38,12 +38,14 @@
3838
"Cari": "Carian",
3939
"Cham": "Cham",
4040
"Cher": "Cherokee",
41+
"Chrs": "Chorasmian",
4142
"Cirt": "Cirth",
4243
"Copt": "Coptic",
4344
"Cprt": "Cypriot",
4445
"Cyrl": "Cyrillic",
4546
"Cyrs": "Old Church Slavonic Cyrillic",
4647
"Deva": "Devanagari",
48+
"Diak": "Dives Akuru",
4749
"Dogr": "Dogra",
4850
"Dsrt": "Deseret",
4951
"Dupl": "Duployan shorthand",
@@ -90,6 +92,7 @@
9092
"Khar": "Kharoshthi",
9193
"Khmr": "Khmer",
9294
"Khoj": "Khojki",
95+
"Kits": "Khitan small script",
9396
"Knda": "Kannada",
9497
"Kore": "Korean",
9598
"Kpel": "Kpelle",
@@ -197,6 +200,7 @@
197200
"Xpeo": "Old Persian",
198201
"Xsux": "Sumero-Akkadian Cuneiform",
199202
"Xsux-alt-short": "S-A Cuneiform",
203+
"Yezi": "Yezidi",
200204
"Yiii": "Yi",
201205
"Zanb": "Zanabazar Square",
202206
"Zinh": "Inherited",

src/cldr-data/main/en-US/territories.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
"en-US": {
44
"identity": {
55
"version": {
6-
"_number": "$Revision$",
7-
"_cldrVersion": "36"
6+
"_cldrVersion": "39"
87
},
98
"language": "en",
109
"territory": "US"
1110
},
1211
"localeDisplayNames": {
1312
"territories": {
14-
"001": "World",
13+
"001": "world",
1514
"002": "Africa",
1615
"003": "North America",
1716
"005": "South America",
@@ -100,6 +99,7 @@
10099
"CR": "Costa Rica",
101100
"CU": "Cuba",
102101
"CV": "Cape Verde",
102+
"CV-alt-variant": "Cabo Verde",
103103
"CW": "Curaçao",
104104
"CX": "Christmas Island",
105105
"CY": "Cyprus",
@@ -201,7 +201,6 @@
201201
"MG": "Madagascar",
202202
"MH": "Marshall Islands",
203203
"MK": "North Macedonia",
204-
"MK-alt-variant": "MK",
205204
"ML": "Mali",
206205
"MM": "Myanmar (Burma)",
207206
"MM-alt-short": "Myanmar",

src/cldr-data/supplemental/plurals.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"supplemental": {
33
"version": {
4-
"_number": "$Revision$",
5-
"_unicodeVersion": "12.1.0",
6-
"_cldrVersion": "36"
4+
"_unicodeVersion": "13.0.0",
5+
"_cldrVersion": "39"
76
},
87
"plurals-type-cardinal": {
98
"af": {
@@ -90,7 +89,7 @@
9089
"pluralRule-count-one": "n % 10 = 1 and n % 100 != 11,71,91 @integer 1, 21, 31, 41, 51, 61, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 81.0, 101.0, 1001.0, …",
9190
"pluralRule-count-two": "n % 10 = 2 and n % 100 != 12,72,92 @integer 2, 22, 32, 42, 52, 62, 82, 102, 1002, … @decimal 2.0, 22.0, 32.0, 42.0, 52.0, 62.0, 82.0, 102.0, 1002.0, …",
9291
"pluralRule-count-few": "n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99 @integer 3, 4, 9, 23, 24, 29, 33, 34, 39, 43, 44, 49, 103, 1003, … @decimal 3.0, 4.0, 9.0, 23.0, 24.0, 29.0, 33.0, 34.0, 103.0, 1003.0, …",
93-
"pluralRule-count-many": "n != 0 and n % 1000000 = 0 @integer 1000000, … @decimal 1000000.0, 1000000.00, 1000000.000, …",
92+
"pluralRule-count-many": "n != 0 and n % 1000000 = 0 @integer 1000000, … @decimal 1000000.0, 1000000.00, 1000000.000, 1000000.0000, ",
9493
"pluralRule-count-other": " @integer 0, 5~8, 10~20, 100, 1000, 10000, 100000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, …"
9594
},
9695
"brx": {
@@ -148,6 +147,10 @@
148147
"pluralRule-count-one": "i = 1 and v = 0 @integer 1",
149148
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
150149
},
150+
"doi": {
151+
"pluralRule-count-one": "i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04",
152+
"pluralRule-count-other": " @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~2.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
153+
},
151154
"dsb": {
152155
"pluralRule-count-one": "v = 0 and i % 100 = 1 or f % 100 = 1 @integer 1, 101, 201, 301, 401, 501, 601, 701, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …",
153156
"pluralRule-count-two": "v = 0 and i % 100 = 2 or f % 100 = 2 @integer 2, 102, 202, 302, 402, 502, 602, 702, 1002, … @decimal 0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 10.2, 100.2, 1000.2, …",
@@ -211,7 +214,8 @@
211214
},
212215
"fr": {
213216
"pluralRule-count-one": "i = 0,1 @integer 0, 1 @decimal 0.0~1.5",
214-
"pluralRule-count-other": " @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
217+
"pluralRule-count-many": "e = 0 and i != 0 and i % 1000000 = 0 and v = 0 or e != 0..5 @integer 1000000, 1c6, 2c6, 3c6, 4c6, 5c6, 6c6, … @decimal 1.0000001c6, 1.1c6, 2.0000001c6, 2.1c6, 3.0000001c6, 3.1c6, …",
218+
"pluralRule-count-other": " @integer 2~17, 100, 1000, 10000, 100000, 1c3, 2c3, 3c3, 4c3, 5c3, 6c3, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 1.0001c3, 1.1c3, 2.0001c3, 2.1c3, 3.0001c3, 3.1c3, …"
215219
},
216220
"fur": {
217221
"pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
@@ -443,6 +447,10 @@
443447
"pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
444448
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
445449
},
450+
"lij": {
451+
"pluralRule-count-one": "i = 1 and v = 0 @integer 1",
452+
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
453+
},
446454
"lkt": {
447455
"pluralRule-count-other": " @integer 0~15, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
448456
},
@@ -588,6 +596,10 @@
588596
"pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
589597
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
590598
},
599+
"pcm": {
600+
"pluralRule-count-one": "i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04",
601+
"pluralRule-count-other": " @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~2.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
602+
},
591603
"pl": {
592604
"pluralRule-count-one": "i = 1 and v = 0 @integer 1",
593605
"pluralRule-count-few": "v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, …",
@@ -644,6 +656,11 @@
644656
"pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
645657
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
646658
},
659+
"sat": {
660+
"pluralRule-count-one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000",
661+
"pluralRule-count-two": "n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000",
662+
"pluralRule-count-other": " @integer 0, 3~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
663+
},
647664
"sc": {
648665
"pluralRule-count-one": "i = 1 and v = 0 @integer 1",
649666
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
@@ -891,4 +908,4 @@
891908
}
892909
}
893910
}
894-
}
911+
}

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
define('GETTEXT_LANGUAGES_TESTDIR', str_replace(DIRECTORY_SEPARATOR, '/', __DIR__));
66

7-
$cmd = escapeshellarg(defined('PHP_BINARY') ? PHP_BINARY : 'php');
7+
$cmd = defined('PHP_BINARY') && PHP_BINARY ? escapeshellarg(PHP_BINARY) : 'php';
88
$cmd .= ' ' . escapeshellarg(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'export-plural-rules');
99

1010
$execOutput = array();

0 commit comments

Comments
 (0)