/** * Extract all translations from the provided file * * Remove all translations containing : * - $ -> auto-generated translation cannot be supported * - :: -> package translations are not taken in account * * @param string $path the file path * @param array $trans_methods an array of regex to catch * * @return array an array dot of found translations */ public function extractTranslationFromPhpFile($path, $trans_methods) { $result = array(); $string = Tools::minifyString(file_get_contents($path)); foreach (array_flatten($trans_methods) as $method) { preg_match_all($method, $string, $matches); foreach ($matches[1] as $k => $v) { if (strpos($v, '$') !== false) { unset($matches[1][$k]); } if (strpos($v, '::') !== false) { unset($matches[1][$k]); } } $result = array_merge($result, array_flip($matches[1])); } return $result; }