Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function _parse()
 {
     $this->_phraseCollector->parse($this->_file);
     foreach ($this->_phraseCollector->getPhrases() as $phrase) {
         $this->_addPhrase($phrase['phrase'], $phrase['line']);
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 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)));
 }