23 $expectedKeywords = UnicodePlural::getPluralKeywords( $targetLanguage );
25 if ( $expectedKeywords ===
null ) {
31 $expectedPluralCount = count( $expectedKeywords );
35 $unsupportedVariables = array_diff(
36 array_keys( $translationPlurals ), array_keys( $definitionPlurals )
39 foreach ( $unsupportedVariables as $unsupportedVariable ) {
43 'translate-checks-smartformat-plural-unsupported',
45 [
'PLAIN',
'{' . $unsupportedVariable .
'}' ],
49 $issues->add( $issue );
52 if ( $expectedPluralCount > 1 ) {
53 $missingVariables = array_diff(
54 array_keys( $definitionPlurals ), array_keys( $translationPlurals )
57 foreach ( $missingVariables as $missingVariable ) {
61 'translate-checks-smartformat-plural-missing',
63 [
'PLAIN',
'{' . $missingVariable .
'}' ],
67 $issues->add( $issue );
72 $commonVariables = array_intersect_key( $translationPlurals, $definitionPlurals );
73 foreach ( $commonVariables as $pluralInstances ) {
74 foreach ( $pluralInstances as $pluralInstance ) {
75 $actualPluralCount = count( $pluralInstance[
'forms' ] );
76 if ( $actualPluralCount !== $expectedPluralCount ) {
80 'translate-checks-smartformat-plural-count',
82 [
'COUNT', $expectedPluralCount ],
83 [
'COUNT', $actualPluralCount ],
84 [
'PLAIN', $pluralInstance[
'original' ] ],
88 $issues->add( $issue );
102 foreach ( array_keys( $definitionPlurals ) as $variable ) {
103 $pre =
'{' .
"$variable:";
105 $insertables[] =
new Insertable(
"$pre$post", $pre, $post );