mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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
This commit is contained in:
parent
dc18c51f32
commit
b25b45aab4
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user