* @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ namespace PrestaShop\TranslationToolsBundle\Translation\Parser; class CrowdinPhpParser { /** * Extracts trans message from PHP tokens. * * @param $file $tokens * @param MessageCatalogue $catalog */ public function parseFileTokens($file) { preg_match_all('/^(\$_\w+\[\'.+\'\]) = \'(.*)\';/m', file_get_contents($file), $matches); foreach ($matches[0] as $key => $match) { yield [ 'message' => $matches[2][$key], 'key' => $matches[1][$key], ]; } } }