From b25b45aab4d519a58bbb428d21539a3ef4e0a37e Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Wed, 25 Jul 2012 11:39:39 +1200 Subject: [PATCH] BUG Fix i18nTextCollector restriction to specific modules i18nTextCollector takes an argument to restrict text collection to specific modules. This used to restrict by limiting the modules scanned by the text collector. But modules can actually provide translations for other modules (see for e.g. CMSMenu#provideI18nEntities) This patch changes the text collector to scan all modules, and then apply the restriction to the output --- i18n/i18nTextCollector.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/i18n/i18nTextCollector.php b/i18n/i18nTextCollector.php index 5c0b493b0..38079cd04 100644 --- a/i18n/i18nTextCollector.php +++ b/i18n/i18nTextCollector.php @@ -75,21 +75,12 @@ class i18nTextCollector extends Object { public function run($restrictToModules = null) { //Debug::message("Collecting text...", false); - $modules = array(); + $modules = scandir($this->basePath); $themeFolders = array(); // A master string tables array (one mst per module) $entitiesByModule = array(); - //Search for and process existent modules, or use the passed one instead - if($restrictToModules && count($restrictToModules)) { - foreach($restrictToModules as $restrictToModule) { - $modules[] = basename($restrictToModule); - } - } else { - $modules = scandir($this->basePath); - } - foreach($modules as $index => $module){ if($module != 'themes') continue; else { @@ -145,6 +136,13 @@ class i18nTextCollector extends Object { } } + // Restrict modules we update to just the specified ones (if any passed) + if($restrictToModules && count($restrictToModules)) { + foreach (array_diff(array_keys($entitiesByModule), $restrictToModules) as $module) { + unset($entitiesByModule[$module]); + } + } + // Write each module language file if($entitiesByModule) foreach($entitiesByModule as $module => $entities) { $this->getWriter()->write($entities, $this->defaultLocale, $this->baseSavePath . '/' . $module);