GetTextTranslationHelper: Make sure we ignore any dotfile or vendor dir

If you are using composer, or ship any other code in dotfile or vendor
directories, we should not parse that for translation.

Signed-off-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
Markus Frosch 2017-05-19 10:46:20 +02:00 committed by Eric Lippmann
parent 1a86c61c2d
commit 43423f9453
1 changed files with 4 additions and 1 deletions

View File

@ -467,10 +467,13 @@ class GettextTranslationHelper
$subdirs = array();
while (($filename = readdir($directoryHandle)) !== false) {
if ($filename[0] === '.' || $filename === 'vendor') {
continue;
}
$filepath = $directory . DIRECTORY_SEPARATOR . $filename;
if (preg_match('@^[^\.].+\.(' . implode('|', $this->sourceExtensions) . ')$@', $filename)) {
$file->fwrite($filepath . PHP_EOL);
} elseif (is_dir($filepath) && !preg_match('@^(\.|\.\.)$@', $filename)) {
} elseif (is_dir($filepath)) {
$subdirs[] = $filepath;
}
}