You are here

public function QtFileDumper::format in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/translation/Dumper/QtFileDumper.php \Symfony\Component\Translation\Dumper\QtFileDumper::format()

Transforms a domain of a message catalogue to its string representation.

Parameters

MessageCatalogue $messages:

string $domain:

Return value

string representation

Overrides FileDumper::format

File

vendor/symfony/translation/Dumper/QtFileDumper.php, line 26

Class

QtFileDumper
QtFileDumper generates ts files from a message catalogue.

Namespace

Symfony\Component\Translation\Dumper

Code

public function format(MessageCatalogue $messages, $domain) {
  $dom = new \DOMDocument('1.0', 'utf-8');
  $dom->formatOutput = true;
  $ts = $dom
    ->appendChild($dom
    ->createElement('TS'));
  $context = $ts
    ->appendChild($dom
    ->createElement('context'));
  $context
    ->appendChild($dom
    ->createElement('name', $domain));
  foreach ($messages
    ->all($domain) as $source => $target) {
    $message = $context
      ->appendChild($dom
      ->createElement('message'));
    $message
      ->appendChild($dom
      ->createElement('source', $source));
    $message
      ->appendChild($dom
      ->createElement('translation', $target));
  }
  return $dom
    ->saveXML();
}