You are here

protected function TMGMTFileformatXLIFF::addTransUnit in Translation Management Tool 7

Adds a single translation unit for a data element.

Parameters

$key: The unique identifier for this data element.

$element: Array with the properties #text and optionally #label.

TMGMTJob $job: Translation job.

1 call to TMGMTFileformatXLIFF::addTransUnit()
TMGMTFileformatXLIFF::addItem in translators/file/tmgmt_file.format.xliff.inc
Adds a job item to the xml export.

File

translators/file/tmgmt_file.format.xliff.inc, line 89

Class

TMGMTFileformatXLIFF
Export to XLIFF format.

Code

protected function addTransUnit($key, $element, TMGMTJob $job) {
  $key_array = tmgmt_ensure_keys_array($key);
  $this
    ->startElement('trans-unit');
  $this
    ->writeAttribute('id', $key);
  $this
    ->writeAttribute('resname', $key);
  $this
    ->startElement('source');
  $this
    ->writeAttribute('xml:lang', $this->job
    ->getTranslator()
    ->mapToRemoteLanguage($this->job->source_language));
  if ($job
    ->getSetting('xliff_cdata')) {
    $this
      ->writeCdata(trim($element['#text']));
  }
  elseif ($job
    ->getSetting('xliff_processing')) {
    $this
      ->writeRaw($this
      ->processForExport($element['#text'], $key_array));
  }
  else {
    $this
      ->text($element['#text']);
  }
  $this
    ->endElement();
  $this
    ->startElement('target');
  $this
    ->writeAttribute('xml:lang', $this->job
    ->getTranslator()
    ->mapToRemoteLanguage($this->job->target_language));
  if (!empty($element['#translation']['#text'])) {
    if ($job
      ->getSetting('xliff_processing')) {
      $this
        ->writeRaw($this
        ->processForExport($element['#translation']['#text'], $key_array));
    }
    else {
      $this
        ->text($element['#translation']['#text']);
    }
  }
  $this
    ->endElement();
  if (isset($element['#label'])) {
    $this
      ->writeElement('note', $element['#label']);
  }
  $this
    ->endElement();
}