/** * {@inheritdoc} */ protected function _parse() { $this->_phraseCollector->parse($this->_file); foreach ($this->_phraseCollector->getPhrases() as $phrase) { $this->_addPhrase($phrase['phrase'], $phrase['line']); } }
/** * Returns an array of phrases that can be used by JS files. * * @return string[] */ protected function _getRegisteredPhrases() { $jsHelperFile = realpath(__DIR__ . '/../../../../../../../../app/code/Magento/Translation/Model/Js/DataProvider.php'); $this->_phraseCollector->parse($jsHelperFile); $result = array(); foreach ($this->_phraseCollector->getPhrases() as $phrase) { $result[] = stripcslashes(trim($phrase['phrase'], "'")); } return $result; }
public function testArguments() { $errors = array(); foreach ($this->_getFiles() as $file) { if (in_array($file, $this->blackList)) { continue; } $this->_phraseCollector->parse($file); foreach ($this->_phraseCollector->getPhrases() as $phrase) { if (preg_match_all('/%(\\d+)/', $phrase['phrase'], $matches) || $phrase['arguments']) { $placeholdersInPhrase = array_unique($matches[1]); if (count($placeholdersInPhrase) != $phrase['arguments']) { $errors[] = $this->_createPhraseError($phrase); } } } } $this->assertEmpty($errors, sprintf("\n%d usages of inconsistency the number of arguments and placeholders were discovered: \n%s", count($errors), implode("\n\n", $errors))); }