protected $_paths = [];
protected $_extensions = ['php', 'phtml'];
- protected $_exclude = ['^\.git'];
+ protected $_exclude = ['\/\.git\/'];
protected $_toTranslate = [];
protected static $_parsed = [];
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));
}
}
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