From fdc20ce078ea8987c9db37fa85e837ac6152ba1e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 8 Nov 2023 16:08:50 +0100 Subject: [PATCH] wip #6462 @0.5 --- src/Translate.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Translate.php b/src/Translate.php index f583e2d..52b0c62 100644 --- a/src/Translate.php +++ b/src/Translate.php @@ -13,7 +13,7 @@ class Translate protected $_paths = []; protected $_extensions = ['php', 'phtml']; - protected $_exclude = ['^\.git']; + protected $_exclude = ['\/\.git\/']; protected $_toTranslate = []; protected static $_parsed = []; @@ -67,8 +67,19 @@ class Translate start_measure('Parse path for translations ' . $path); $res = []; $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); + /** @var SplFileInfo $p */ foreach ($iterator as $p) { if ($p->isFile() && in_array($p->getExtension(), $this->_extensions)) { + $excluded = false; + foreach ($this->_exclude as $exclude) { + if (preg_match('/' . $exclude . '/', $p->getPathname())) { + $excluded = true; + break; + } + } + if (!$excluded) { + continue; + } $res = array_merge($res, static::extractTextsToTranslate($p)); } } @@ -88,7 +99,7 @@ class Translate return []; } $cacheKey = 'totranslate_' . Files::hashFileAttributes($file->getPathname()); - return Cache::remember($cacheKey,3600, function () use ($file) { + return Cache::remember($cacheKey, 3600, function () use ($file) { $c = file_get_contents($file); $res = []; // @link https://regex101.com/r/uD0eT1/4 -- 2.39.5