public function QtFileDumper::format in Plug 7
Transforms a domain of a message catalogue to its string representation.
Parameters
MessageCatalogue $messages:
string $domain:
Return value
string representation
Overrides FileDumper::format
File
- lib/
Symfony/ translation/ Dumper/ QtFileDumper.php, line 26
Class
- QtFileDumper
- QtFileDumper generates ts files from a message catalogue.
Namespace
Symfony\Component\Translation\DumperCode
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();
}