Skip to content

Commit

Permalink
Moved jms:reference elements after source and target elements for XLI…
Browse files Browse the repository at this point in the history
…FF 1.2 compatibility.
  • Loading branch information
ChMat committed May 11, 2012
1 parent 3f65e86 commit c461410
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions Translation/Dumper/XliffDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ public function dump(MessageCatalogue $catalogue, $domain = 'messages')
$unit->setAttribute('id', $i++);
$unit->setAttribute('resname', $id);

$unit->appendChild($source = $doc->createElement('source'));
if (preg_match('/[<>&]/', $message->getSourceString())) {
$source->appendChild($doc->createCDATASection($message->getSourceString()));
} else {
$source->appendChild($doc->createTextNode($message->getSourceString()));
}

$unit->appendChild($target = $doc->createElement('target'));
if (preg_match('/[<>&]/', $message->getLocaleString())) {
$target->appendChild($doc->createCDATASection($message->getLocaleString()));
} else {
$target->appendChild($doc->createTextNode($message->getLocaleString()));
}

if ($message->isNew()) {
$target->setAttribute('state', 'new');
}

if ($sources = $message->getSources()) {
foreach ($sources as $source) {
if ($source instanceof FileSource) {
Expand All @@ -120,23 +138,6 @@ public function dump(MessageCatalogue $catalogue, $domain = 'messages')
$unit->setAttribute('extradata', 'Meaning: '.$meaning);
}

$unit->appendChild($source = $doc->createElement('source'));
if (preg_match('/[<>&]/', $message->getSourceString())) {
$source->appendChild($doc->createCDATASection($message->getSourceString()));
} else {
$source->appendChild($doc->createTextNode($message->getSourceString()));
}

$unit->appendChild($target = $doc->createElement('target'));
if (preg_match('/[<>&]/', $message->getLocaleString())) {
$target->appendChild($doc->createCDATASection($message->getLocaleString()));
} else {
$target->appendChild($doc->createTextNode($message->getLocaleString()));
}

if ($message->isNew()) {
$target->setAttribute('state', 'new');
}
}

return $doc->saveXML();
Expand Down

0 comments on commit c461410

Please sign in to comment.