Skip to content

Commit 2f54e46

Browse files
committed
Ignore script tags listed in plural rules (why are even there?)
1 parent a2157f9 commit 2f54e46

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

bin/import-cldr-data

Lines changed: 12 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,

0 commit comments

Comments
 (0)