Fallbacks didn't work at all for the new plural rule system. I fixed it by moving the getPluralRules() and getCompiledPluralRules() calls near to the readPHPFile() calls, before merging is done. Then I factored out the resulting code to readSourceFilesAndRegisterDeps(). * Removed pluralRules from mergeableMapKeys, it isn't one * Added compiledPluralRules to allKeys so that it will be merged * When a language is not present in the CLDR XML files, return null from getPluralRules() and getCompiledPluralRules() so that the fallback rules won't be overridden with an empty array. Normalised it back to an empty array in the unlikely event that there is no plural data in the fallback sequence at all, even in English. * Fixed private function, "protected" is the way to say private here. Change-Id: I3a008ef7f6ed7aaa15ad25ad796f7a2b8f827fa2
31 lines
915 B
PHP
31 lines
915 B
PHP
<?php
|
|
|
|
class LocalisationCacheTest extends MediaWikiTestCase {
|
|
public function testPuralRulesFallback() {
|
|
$cache = Language::getLocalisationCache();
|
|
|
|
$this->assertEquals(
|
|
$cache->getItem( 'ru', 'pluralRules' ),
|
|
$cache->getItem( 'os', 'pluralRules' ),
|
|
'os plural rules (undefined) fallback to ru (defined)'
|
|
);
|
|
|
|
$this->assertEquals(
|
|
$cache->getItem( 'ru', 'compiledPluralRules' ),
|
|
$cache->getItem( 'os', 'compiledPluralRules' ),
|
|
'os compiled plural rules (undefined) fallback to ru (defined)'
|
|
);
|
|
|
|
$this->assertNotEquals(
|
|
$cache->getItem( 'ksh', 'pluralRules' ),
|
|
$cache->getItem( 'de', 'pluralRules' ),
|
|
'ksh plural rules (defined) dont fallback to de (defined)'
|
|
);
|
|
|
|
$this->assertNotEquals(
|
|
$cache->getItem( 'ksh', 'compiledPluralRules' ),
|
|
$cache->getItem( 'de', 'compiledPluralRules' ),
|
|
'ksh compiled plural rules (defined) dont fallback to de (defined)'
|
|
);
|
|
}
|
|
}
|