Esempio n. 1
0
 /**
  * Get dictionary generator
  *
  * @return \Magento\Tools\I18n\Code\Dictionary\Generator
  */
 public static function getDictionaryGenerator()
 {
     if (null === self::$_dictionaryGenerator) {
         $filesCollector = new FilesCollector();
         $phraseCollector = new Parser\Adapter\Php\Tokenizer\PhraseCollector(new Parser\Adapter\Php\Tokenizer());
         $adapters = array('php' => new Parser\Adapter\Php($phraseCollector), 'js' => new Parser\Adapter\Js(), 'xml' => new Parser\Adapter\Xml());
         $parser = new Parser\Parser($filesCollector, self::_getFactory());
         $parserContextual = new Parser\Contextual($filesCollector, self::_getFactory(), self::_getContext());
         foreach ($adapters as $type => $adapter) {
             $parser->addAdapter($type, $adapter);
             $parserContextual->addAdapter($type, $adapter);
         }
         self::$_dictionaryGenerator = new Dictionary\Generator($parser, $parserContextual, self::_getFactory(), new Dictionary\Options\ResolverFactory());
     }
     return self::$_dictionaryGenerator;
 }
Esempio n. 2
0
 public function testWritingPhrases()
 {
     $baseDir = 'WritingPhrases';
     $filesOptions = array('file1', 'file2');
     $optionResolver = $this->getMock('Magento\\Tools\\I18n\\Code\\Dictionary\\Options\\Resolver', [], [], '', false);
     $optionResolver->expects($this->once())->method('getOptions')->will($this->returnValue($filesOptions));
     $this->optionsResolverFactory->expects($this->once())->method('create')->with($this->equalTo($baseDir), $this->equalTo(false))->will($this->returnValue($optionResolver));
     $phrases = array($this->getMock('Magento\\Tools\\I18n\\Code\\Dictionary\\Phrase', array(), array(), '', false), $this->getMock('Magento\\Tools\\I18n\\Code\\Dictionary\\Phrase', array(), array(), '', false));
     $this->parserMock->expects($this->once())->method('getPhrases')->will($this->returnValue($phrases));
     $this->writerMock->expects($this->at(0))->method('write')->with($phrases[0]);
     $this->writerMock->expects($this->at(1))->method('write')->with($phrases[1]);
     $this->generator->generate($baseDir, 'file.csv');
 }