src/Serializer.php
public function beginExport(TranslatableInterface $translatable, $targetLang) {

    $this->openMemory();
    $this->setIndent(TRUE);
    $this->setIndentString(' ');
    $this->startDocument('1.0', 'UTF-8');

    // Root element with schema definition.
    $this->startElement('xliff');
    $this->writeAttribute('version', '1.2');
    $this->writeAttribute('xmlns:xlf', 'urn:oasis:names:tc:xliff:document:1.2');
    $this->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
    $this->writeAttribute('xmlns:html', 'http://www.w3.org/1999/xhtml');
    $this->writeAttribute('xsi:schemaLocation', 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd');

    // File element.
    $this->startElement('file');
    $this->writeAttribute('original', 'xliff-core-1.2-strict.xsd');
    $this->writeAttribute('source-language', $this->sourceLang);
    $this->writeAttribute('target-language', $targetLang);
    $this->writeAttribute('datatype', 'plaintext');

    // Date needs to be in ISO-8601 UTC.
    $this->writeAttribute('date', date('Y-m-d\Th:m:i\Z'));

    $this->startElement('header');
    $this->startElement('phase-group');
    $this->startElement('phase');
    $this->writeAttribute('tool-id', 'eggs-n-cereal');
    $this->writeAttribute('phase-name', 'extraction');
    $this->writeAttribute('process-name', 'extraction');
    $this->writeAttribute('job-id', $translatable->getIdentifier());

    $this->endElement();
    $this->endElement();
    $this->startElement('tool');
    $this->writeAttribute('tool-id', 'eggs-n-cereal');
    $this->writeAttribute('tool-name', 'Eggs-n-Cereal XLIFF Serializer');
    $this->endElement();
    $this->endElement();

    return $this->outputMemory() . '<body>';
  }
public function beginExport(TranslatableInterface $translatable, $targetLang) {

    $this->openMemory();
    $this->setIndent(TRUE);
    $this->setIndentString(' ');
    $this->startDocument('1.0', 'UTF-8');

    // Root element with schema definition.
    $this->startElement('xliff');
    $this->writeAttribute('version', '1.2');
    $this->writeAttribute('xmlns:xlf', 'urn:oasis:names:tc:xliff:document:1.2');
    $this->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
    $this->writeAttribute('xmlns:html', 'http://www.w3.org/1999/xhtml');
    $this->writeAttribute('xsi:schemaLocation', 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd');

    // File element.
    $this->startElement('file');
    $this->writeAttribute('original', 'xliff-core-1.2-strict.xsd');
    $this->writeAttribute('source-language', $this->sourceLang);
    $this->writeAttribute('target-language', $targetLang);
    $this->writeAttribute('datatype', 'plaintext');

    // Date needs to be in ISO-8601 UTC.
    $this->writeAttribute('date', date('Y-m-d\Th:m:i\Z'));

    $this->startElement('header');
    $this->startElement('phase-group');
    $this->startElement('phase');
    $this->writeAttribute('tool-id', 'eggs-n-cereal');
    $this->writeAttribute('phase-name', 'extraction');
    $this->writeAttribute('process-name', 'extraction');
    $this->writeAttribute('job-id', $translatable->getIdentifier());

    $this->endElement();
    $this->endElement();
    $this->startElement('tool');
    $this->writeAttribute('tool-id', 'eggs-n-cereal');
    $this->writeAttribute('tool-name', 'Eggs-n-Cereal XLIFF Serializer');
    $this->endElement();
    $this->endElement();

    return $this->outputMemory() . '<body>';
  }
public function beginExport ( TranslatableInterface $ translatable , $ targetLang ) { $ this -> openMemory ( ) ; $ this -> setIndent ( TRUE ) ; $ this -> setIndentString ( ' ' ) ; $ this -> startDocument ( '1.0' , 'UTF-8' ) ; // Root element with schema definition. $ this -> startElement ( 'xliff' ) ; $ this -> writeAttribute ( 'version' , '1.2' ) ; $ this -> writeAttribute ( 'xmlns:xlf' , 'urn:oasis:names:tc:xliff:document:1.2' ) ; $ this -> writeAttribute ( 'xmlns:xsi' , 'http://www.w3.org/2001/XMLSchema-instance' ) ; $ this -> writeAttribute ( 'xmlns:html' , 'http://www.w3.org/1999/xhtml' ) ; $ this -> writeAttribute ( 'xsi:schemaLocation' , 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd' ) ; // File element. $ this -> startElement ( 'file' ) ; $ this -> writeAttribute ( 'original' , 'xliff-core-1.2-strict.xsd' ) ; $ this -> writeAttribute ( 'source-language' , $ this -> sourceLang ) ; $ this -> writeAttribute ( 'target-language' , $ targetLang ) ; $ this -> writeAttribute ( 'datatype' , 'plaintext' ) ; // Date needs to be in ISO-8601 UTC. $ this -> writeAttribute ( 'date' , date ( 'Y-m-d\Th:m:i\Z' ) ) ; $ this -> startElement ( 'header' ) ; $ this -> startElement ( 'phase-group' ) ; $ this -> startElement ( 'phase' ) ; $ this -> writeAttribute ( 'tool-id' , 'eggs-n-cereal' ) ; $ this -> writeAttribute ( 'phase-name' , 'extraction' ) ; $ this -> writeAttribute ( 'process-name' , 'extraction' ) ; $ this -> writeAttribute ( 'job-id' , $ translatable -> getIdentifier ( ) ) ; $ this -> endElement ( ) ; $ this -> endElement ( ) ; $ this -> startElement ( 'tool' ) ; $ this -> writeAttribute ( 'tool-id' , 'eggs-n-cereal' ) ; $ this -> writeAttribute ( 'tool-name' , 'Eggs-n-Cereal XLIFF Serializer' ) ; $ this -> endElement ( ) ; $ this -> endElement ( ) ; return $ this -> outputMemory ( ) . '<body>' ; }
Starts an export.

@param TranslatableInterface $translatable
The translatable for which we will be generating an XLIFF.

@param string $targetLang
The language code of the target language for this XLIFF.

@return string
The generated XML.
Starts an export .