You are here

class QtFileDumper 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

QtFileDumper generates ts files from a message catalogue.

@author Benjamin Eberlei <kontakt@beberlei.de>

Hierarchy

Expanded class hierarchy of QtFileDumper

1 file declares its use of QtFileDumper
QtFileDumperTest.php in vendor/symfony/translation/Tests/Dumper/QtFileDumperTest.php

File

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

Namespace

Symfony\Component\Translation\Dumper
View source
class QtFileDumper extends FileDumper {

  /**
   * {@inheritdoc}
   */
  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();
  }

  /**
   * {@inheritdoc}
   */
  protected function getExtension() {
    return 'ts';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileDumper::$backup private property Make file backup before the dump.
FileDumper::$relativePathTemplate protected property A template for the relative paths to files. 1
FileDumper::dump public function Dumps the message catalogue. Overrides DumperInterface::dump 1
FileDumper::getRelativePath private function Gets the relative file path using the template.
FileDumper::setBackup public function Sets backup flag.
FileDumper::setRelativePathTemplate public function Sets the template for the relative paths to files.
QtFileDumper::format public function Transforms a domain of a message catalogue to its string representation. Overrides FileDumper::format
QtFileDumper::getExtension protected function Gets the file extension of the dumper. Overrides FileDumper::getExtension