}
- public function addPath($path)
+ public function addPath($path, $sectionLabel = null)
{
- $this->_paths[] = $path;
+ if (null === $sectionLabel) {
+ $this->_paths[] = $path;
+ } else {
+ $this->_paths[$sectionLabel] = $path;
+ }
}
public function clearPaths()
$this->_extensions = array_unique($this->_extensions);
$this->_paths = array_unique($this->_paths);
- foreach ($this->_paths as $path) {
+ foreach ($this->_paths as $sectionLabel => $path) {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
foreach ($iterator as $p) {
if ($p->isFile()) {
- $this->_parseFile($p);
+ $this->_parseFile($p, $sectionLabel);
}
}
}
- $this->_toTranslate = array_unique($this->_toTranslate);
}
- protected function _parseFile(SplFileInfo $file)
+ protected function _parseFile(SplFileInfo $file, $sectionLabel)
{
if (!in_array($file->getExtension(), $this->_extensions)) {
return;
}
- $this->_toTranslate = array_merge($this->_toTranslate, self::extractTextsToTranslate($file));
+ if (!isset($this->_toTranslate[$sectionLabel])) {
+ $this->_toTranslate[$sectionLabel] = [];
+ }
+ $this->_toTranslate[$sectionLabel] = array_merge($this->_toTranslate[$sectionLabel], self::extractTextsToTranslate($file));
}
public static function extractTextsToTranslate(SplFileInfo $file)