コード例 #1
0
    public function testPluralParsing()
    {
        $content = <<<EOT
msgid "foo"
msgid_plural "bar"
msgstr[0] "baz"
msgstr[1] "qux"
msgstr[2] "bux"

msgid ""
"bar"
msgid_plural ""
"baz"
msgstr[0] "baz "
"bux"
msgstr[1] "qux "
"foo"
"bar"
EOT;
        $parser = new PoeditParser('foo');
        $file = $parser->parse($content);
        $this->assertCount(3, $file->getString('foo')->getPlurals());
        $this->assertCount(2, $file->getString('bar')->getPlurals());
        $this->assertEquals('baz bux', $file->getString('bar')->getPlural(0));
    }
コード例 #2
0
 public function testXgettext()
 {
     $output = __DIR__ . '/Resources/dump/' . $this->generateRandomFileName();
     $files = array(__DIR__ . '/Resources/test.html', __DIR__ . '/Resources/test.js');
     new Xgettext($files, $output, array('__'));
     $parser = new PoeditParser($output);
     $file = $parser->parse();
     $this->assertCount(17, $file->getStrings());
     unlink($output);
 }
コード例 #3
0
 public function testXgettextHandlebarsCommand()
 {
     $output = __DIR__ . '/Resources/dump/' . $this->generateRandomFileName();
     exec(__DIR__ . '/../../../bin/xgettext -l "handlebars" -o "' . $output . '" -k "_t" -k "_n:1,2" "' . __DIR__ . '/Resources/test.hbs"');
     $parser = new PoeditParser($output);
     $file = $parser->parse();
     unlink($output);
     $this->assertInstanceOf('\\Xgettext\\Poedit\\PoeditFile', $file);
     $this->assertCount(3, $file->getStrings());
 }
コード例 #4
0
 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'));
 }