コード例 #1
0
    public function testTargetAttributesMetadataIsSetInFile()
    {
        $catalogue = new MessageCatalogue('en_US');
        $catalogue->add(array('foo' => 'bar'));
        $catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation')));
        $tempDir = sys_get_temp_dir();
        $dumper = new XliffFileDumper();
        $dumper->dump($catalogue, array('path' => $tempDir, 'default_locale' => 'fr_FR'));
        $content = <<<EOT
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
  <file source-language="fr-FR" target-language="en-US" datatype="plaintext" original="file.ext">
    <body>
      <trans-unit id="acbd18db4cc2f85cedef654fccc4a4d8" resname="foo">
        <source>foo</source>
        <target state="needs-translation">bar</target>
      </trans-unit>
    </body>
  </file>
</xliff>

EOT;
        $this->assertEquals($content, file_get_contents($tempDir . '/messages.en_US.xlf'));
        unlink($tempDir . '/messages.en_US.xlf');
    }
コード例 #2
0
 public function testFormatCatalogueWithTargetAttributesMetadata()
 {
     $catalogue = new MessageCatalogue('en_US');
     $catalogue->add(array('foo' => 'bar'));
     $catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation')));
     $dumper = new XliffFileDumper();
     $this->assertStringEqualsFile(__DIR__ . '/../fixtures/resources-target-attributes.xlf', $dumper->formatCatalogue($catalogue, 'messages', array('default_locale' => 'fr_FR')));
 }
コード例 #3
0
 public function testDump()
 {
     $catalogue = new MessageCatalogue('en');
     $catalogue->add(array('foo' => 'bar', 'key' => ''));
     $tempDir = sys_get_temp_dir();
     $dumper = new XliffFileDumper();
     $dumper->dump($catalogue, array('path' => $tempDir));
     $this->assertEquals(file_get_contents(__DIR__ . '/../fixtures/resources-clean.xlf'), file_get_contents($tempDir . '/messages.en.xlf'));
     unlink($tempDir . '/messages.en.xlf');
 }
コード例 #4
0
 public function testDumpWithTargetAttributesMetadata()
 {
     $catalogue = new MessageCatalogue('en_US');
     $catalogue->add(array('foo' => 'bar'));
     $catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation')));
     $this->tempDir = sys_get_temp_dir();
     $dumper = new XliffFileDumper();
     $dumper->dump($catalogue, array('path' => $this->tempDir, 'default_locale' => 'fr_FR'));
     $this->assertEquals(file_get_contents(__DIR__ . '/../fixtures/resources-target-attributes.xlf'), file_get_contents($this->tempDir . '/messages.en_US.xlf'));
     unlink($this->tempDir . '/messages.en_US.xlf');
 }
コード例 #5
0
ファイル: XliffFileDumperTest.php プロジェクト: scrobot/Lumen
 public function testDump()
 {
     $catalogue = new MessageCatalogue('en_US');
     $catalogue->add(array('foo' => 'bar', 'key' => '', 'key.with.cdata' => '<source> & <target>'));
     $catalogue->setMetadata('foo', array('notes' => array(array('priority' => 1, 'from' => 'bar', 'content' => 'baz'))));
     $catalogue->setMetadata('key', array('notes' => array(array('content' => 'baz'), array('content' => 'qux'))));
     $tempDir = sys_get_temp_dir();
     $dumper = new XliffFileDumper();
     $dumper->dump($catalogue, array('path' => $tempDir, 'default_locale' => 'fr_FR'));
     $this->assertEquals(file_get_contents(__DIR__ . '/../fixtures/resources-clean.xlf'), file_get_contents($tempDir . '/messages.en_US.xlf'));
     unlink($tempDir . '/messages.en_US.xlf');
 }