public function testPluralDump() { $this->file = new PoeditFile(); $this->file->addString(new PoeditPluralString('foo', 'foo plural', array('plural one', 'plural two', 'last plural'))); $filename = $this->generateRandomFileName(); $basePath = __DIR__ . '/../Resources/dump'; $output = $basePath . '/' . $filename; $dumper = new PoeditDumper($output); $dumper->dump($this->file, null, true); $parser = new PoeditParser($output); $file = $parser->parse(); unlink($output); $strings = $file->getStrings(); $this->assertCount(1, $strings); $this->assertTrue($file->hasString('foo')); $this->assertEquals($file->getString('foo')->getPlurals(), array('plural one', 'plural two', 'last plural')); }
public function __construct(array $files, $output, array $keywords = array('_'), $parser = 'javascript', $enc = 'UTF-8', $cli = false) { $this->cli = $cli; $parser = 'Xgettext\\Parser\\' . ucfirst(strtolower($parser)) . 'Parser'; if (empty($files)) { throw new InvalidArgumentException('You did not provide any input file.'); } if (empty($output)) { throw new InvalidArgumentException('You did not provide any output file.'); } $poeditFile = new PoeditFile(); foreach ($files as $file) { try { $fileParser = new $parser($file, $keywords); $poeditFile->addStrings($fileParser->parse()); } catch (Exception $e) { throw new InvalidArgumentException(sprintf('"%s" parser does not exist', $parser)); } } $poeditDumper = new PoeditDumper($output); $poeditDumper->dump($poeditFile, null, false, $enc); }