Merge pull request #2295 from JayDevlin/patch-1

BUGFIX i18n module load order in i18n::include_by_locale()
This commit is contained in:
Ingo Schommer 2013-10-13 01:43:57 -07:00
commit 14e5c80dad
4 changed files with 14 additions and 3 deletions

View File

@ -2506,7 +2506,8 @@ class i18n extends Object implements TemplateGlobalProvider {
$sortedModules = array();
foreach ($order as $module) {
if (isset($modules[$module])) $sortedModules[$module] = $modules[$module];
}
}
$sortedModules = array_reverse($sortedModules, true);
// Loop in reverse order, meaning the translator with the highest priority goes first
$translators = array_reverse(self::get_translators(), true);

View File

@ -1,3 +1,4 @@
de:
i18nTestModule:
OTHERENTITY: Other Entity (de)
PRIORITYNOTICE: High Module Priority (de)
OTHERENTITY: Other Entity (de)

View File

@ -11,5 +11,6 @@ de:
WITHNAMESPACE: Include Entity with Namespace (de)
LAYOUTTEMPLATE: Layout Template (de)
SPRINTFNAMESPACE: My replacement: %s (de)
PRIORITYNOTICE: Low Module Priority (de)
i18nTestModuleInclude.ss:
SPRINTFINCLUDENAMESPACE: My include replacement: %s (de)
SPRINTFINCLUDENAMESPACE: My include replacement: %s (de)

View File

@ -435,6 +435,9 @@ class i18nTest extends SapphireTest {
$this->assertFalse($adapter->isTranslated('i18nTestModule.ENTITY', 'af'),
'Non-existing unloaded entity not available before call'
);
// set _fakewebroot module priority
Config::inst()->update('i18n', 'module_priority', array('subfolder','i18ntestmodule'));
i18n::include_by_locale('de');
@ -444,6 +447,11 @@ class i18nTest extends SapphireTest {
$this->assertTrue($adapter->isTranslated('i18nTestTheme1.LAYOUTTEMPLATE', null, 'de'), 'Includes theme files');
$this->assertTrue($adapter->isTranslated('i18nTestModule.OTHERENTITY', null, 'de'), 'Includes submodule files');
// check module priority
$this->assertEquals($adapter->translate('i18nTestModule.PRIORITYNOTICE', 'de'),
'High Module Priority (de)'
);
SS_ClassLoader::instance()->popManifest();
}