@@ -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 }
0 commit comments