8000 [Translator][Loader] added XLIFF 2.0 support. by aitboudad · Pull Request #15717 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Translator][Loader] added XLIFF 2.0 support. #15717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 16, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
apply some fixes.
  • Loading branch information
aitboudad committed Sep 7, 2015
commit ace6042d893f2cdb887d80ca56c433b01b142c0b
8 changes: 3 additions & 5 deletions src/Symfony/Component/Translation/Loader/XliffFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private function extract($resource, MessageCatalogue $catalogue, $domain)
}

$xliffVersion = $this->getVersionNumber($dom);
$this->validateSchema($xliffVersion, $dom, $this->getSchema($xliffVersion, $dom));
$this->validateSchema($xliffVersion, $dom, $this->getSchema($xliffVersion));

if ('1.2' === $xliffVersion) {
$this->extractXliff1($dom, $catalogue, $domain);
Expand Down Expand Up @@ -159,6 +159,7 @@ private function utf8ToCharset($content, $encoding = null)
}

/**
* @param string $file
* @param \DOMDocument $dom
* @param string $schema source of the schema
*
Expand All @@ -178,10 +179,7 @@ private function validateSchema($file, \DOMDocument $dom, $schema)
libxml_use_internal_errors($internalErrors);
}

/**
* @return string
*/
private function getSchema($xliffVersion, $dom)
private function getSchema($xliffVersion)
{
if ('1.2' === $xliffVersion) {
$schemaSource = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-1.2-strict.xsd');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public function testLoadVersion2()

$domains = $catalogue->all();
$this->assertCount(3, $domains['domain1']);
$this->assertContainsOnly('string', $catalogue->all('domain1'));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add $this->assertContainsOnly('string', $catalogue->all('domain1')); as in testLoad to be sure that the Xliff2 implementation does not get broken in the future by returning nodes without casting them (as done recently for Xliff 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Notes aren't assigned to specific segments, but to whole units, so there's no way to do a mapping
$this->assertEmpty($catalogue->getMetadata());
Expand Down
0