You are here

public function Xliff::import in Translation Management Tool 8

Converts an exported file content back to the translated data.

Parameters

string $imported_file: Path to a file or an XML string to import.

bool $is_file: (optional) Whether $imported_file is the path to a file or not.

Return value

Translated data array.

Overrides FormatInterface::import

File

translators/tmgmt_file/src/Plugin/tmgmt_file/Format/Xliff.php, line 246

Class

Xliff
Export to XLIFF format.

Namespace

Drupal\tmgmt_file\Plugin\tmgmt_file\Format

Code

public function import($imported_file, $is_file = TRUE) {
  if ($this
    ->getImportedXML($imported_file, $is_file) === FALSE) {
    return FALSE;
  }
  $phase = $this->importedXML
    ->xpath("//xliff:phase[@phase-name='extraction']");
  $phase = reset($phase);
  $job = Job::load((string) $phase['job-id']);
  return \Drupal::service('tmgmt.data')
    ->unflatten($this
    ->getImportedTargets($job));
}