Skip to content

Commit cabbcff

Browse files
authored
Update CLDR data from 47 to 48.1 (#66)
* Ignore "menu" attributes in locale display names * Ignore script tags listed in plural rules (why are even there?) * Update CLDR data from 47 to 48.1
1 parent a5dc1b2 commit cabbcff

8 files changed

Lines changed: 3678 additions & 15 deletions

File tree

bin/import-cldr-data

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,23 @@ class Plurals extends Processor
390390
'root' => '',
391391
);
392392
$unrecognizedLocaleCodes = array();
393+
$m = null;
393394
foreach ($xPluralRulesList as $xPluralRules) {
394395
$locales = preg_split('/\s+/', (string) $xPluralRules->getAttribute('locales'), -1, PREG_SPLIT_NO_EMPTY);
395396
if ($locales === array()) {
396397
throw new RuntimeException('No locales found in pluralRules element');
397398
}
399+
$localesWithScript = array();
400+
foreach ($locales as $locale) {
401+
if (preg_match('/^([a-z]{2,3})[_\-][A-Z][a-z]{3}$/', $locale, $m)) {
402+
$localesWithScript[$locale] = $m[1];
403+
}
404+
}
405+
$missingLocales = array_diff($localesWithScript, $locales);
406+
if ($missingLocales !== array()) {
407+
throw new RuntimeException("Found locales with script without matching locales without script:-\n" . implode("\n- ", $missingLocales));
408+
}
409+
$locales = array_diff($locales, array_keys($localesWithScript));
398410
$elements = array(
399411
'pluralRule-count-zero' => null,
400412
'pluralRule-count-one' => null,
@@ -497,12 +509,18 @@ abstract class LocaleDisplayName extends Processor
497509
$data = array();
498510
$xpath = new DOMXPath($doc);
499511
$xElementList = $xpath->query($this->getXPathSelector());
512+
$expectedKeys = array();
500513
foreach ($xElementList as $xElement) {
501514
$type = (string) $xElement->getAttribute('type');
502515
if ($type === '') {
503516
throw new RuntimeException('Missing type attribute');
504517
}
505518
$key = str_replace('_', '-', $type);
519+
$menu = (string) $xElement->getAttribute('menu');
520+
if ($menu !== '') {
521+
$expectedKeys[] = $key;
522+
continue;
523+
}
506524
$alt = (string) $xElement->getAttribute('alt');
507525
if ($alt !== '') {
508526
$key = "{$key}-alt-{$alt}";
@@ -512,6 +530,11 @@ abstract class LocaleDisplayName extends Processor
512530
}
513531
$data[$key] = (string) $xElement->textContent;
514532
}
533+
foreach (array_unique($expectedKeys) as $expectedKey) {
534+
if (!isset($data[$expectedKey])) {
535+
throw new RuntimeException("Missing expected key {$expectedKey}");
536+
}
537+
}
515538
if ($data === array()) {
516539
throw new RuntimeException('No elements found');
517540
}

gh-pages/public/data/versions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[
2+
"48.1",
23
"47",
34
"46.1",
45
"45",

0 commit comments

Comments
 (0)