Skip to content
This repository
Browse code

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
  • Loading branch information...
commit b25b45aab4d519a58bbb428d21539a3ef4e0a37e 1 parent dc18c51
Hamish Friedlander authored July 25, 2012

Showing 1 changed file with 8 additions and 10 deletions. Show diff stats Hide diff stats

  1. 18  i18n/i18nTextCollector.php
18  i18n/i18nTextCollector.php
@@ -75,21 +75,12 @@ public function getWriter() {
75 75
 	public function run($restrictToModules = null) {
76 76
 		//Debug::message("Collecting text...", false);
77 77
 		
78  
-		$modules = array();
  78
+		$modules = scandir($this->basePath);
79 79
 		$themeFolders = array();
80 80
 		
81 81
 		// A master string tables array (one mst per module)
82 82
 		$entitiesByModule = array();
83 83
 		
84  
-		//Search for and process existent modules, or use the passed one instead
85  
-		if($restrictToModules && count($restrictToModules)) {
86  
-			foreach($restrictToModules as $restrictToModule) {
87  
-				$modules[] = basename($restrictToModule);
88  
-			}
89  
-		} else {
90  
-			$modules = scandir($this->basePath);
91  
-		}
92  
-		
93 84
 		foreach($modules as $index => $module){
94 85
 			if($module != 'themes') continue;
95 86
 			else {
@@ -145,6 +136,13 @@ public function run($restrictToModules = null) {
145 136
 			}			
146 137
 		}
147 138
 
  139
+		// Restrict modules we update to just the specified ones (if any passed)
  140
+		if($restrictToModules && count($restrictToModules)) {
  141
+			foreach (array_diff(array_keys($entitiesByModule), $restrictToModules) as $module) {
  142
+				unset($entitiesByModule[$module]);
  143
+			}
  144
+		}
  145
+
148 146
 		// Write each module language file
149 147
 		if($entitiesByModule) foreach($entitiesByModule as $module => $entities) {
150 148
 			$this->getWriter()->write($entities, $this->defaultLocale, $this->baseSavePath . '/' . $module);

0 notes on commit b25b45a

Please sign in to comment.
Something went wrong with that request. Please try again.