Skip to content

Commit

Permalink
fix xliff file dumper
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Jan 28, 2017
1 parent 439892b commit 1e38274
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration($container);
$config = $this->processConfiguration($configuration, $configs);

// this can be removed, as soon as https://github.com/symfony/symfony/pull/21442 is merged
$container->setParameter('translation.dumper.xliff.class', XliffFileDumper::class);

$requestBuilder = (new Definition(RequestBuilder::class))
Expand All @@ -36,7 +35,7 @@ public function load(array $configs, ContainerBuilder $container)
->addArgument(new Reference($config['httplug_client']))
->addArgument(new Reference($config['httplug_uri_factory']));

$apiDef = $container->register('php_translation.adapter.loco.raw');
$apiDef = $container->register('php_translation.adapter.phrase_app.raw');
$apiDef->setClass(PhraseAppClient::class)
->setFactory([PhraseAppClient::class, 'configure'])
->addArgument($clientConfigurator)
Expand Down
6 changes: 3 additions & 3 deletions src/Bridge/Symfony/XliffFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ private function dumpXliff1($defaultLocale, MessageCatalogue $messages, $domain,

// changed for phrase app
$translation->setAttribute('id', md5($source));
$translation->setAttribute('resname', $source);
$translation->setAttribute('resname', "$domain::$source");

$s = $translation->appendChild($dom->createElement('source'));
$s->appendChild($dom->createTextNode("$domain::$source"));
$s->appendChild($dom->createTextNode($source));

// Does the target contain characters requiring a CDATA section?
$text = 1 === preg_match('/[&<>]/', $target) ? $dom->createCDATASection($target) : $dom->createTextNode($target);
Expand Down Expand Up @@ -152,7 +152,7 @@ private function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain,
$segment = $translation->appendChild($dom->createElement('segment'));

$s = $segment->appendChild($dom->createElement('source'));
$s->appendChild($dom->createTextNode("$domain::$source"));
$s->appendChild($dom->createTextNode($source));

// Does the target contain characters requiring a CDATA section?
$text = 1 === preg_match('/[&<>]/', $target) ? $dom->createCDATASection($target) : $dom->createTextNode($target);
Expand Down

0 comments on commit 1e38274

Please sign in to comment.