/** * When it's called, XML file is parsed (using parser set in $xmlParser) * or cache is loaded, if available. * * @return void */ public function initializeObject() { if ($this->cache->has(md5($this->sourcePath))) { $this->xmlParsedData = $this->cache->get(md5($this->sourcePath)); } else { $this->xmlParsedData = $this->xmlParser->getParsedData($this->sourcePath); $this->cache->set(md5($this->sourcePath), $this->xmlParsedData); } }
/** * Read the xliff file and create the desired json * * @param string $xliffPathAndFilename The file to read * @param string $packageKey * @param string $sourceName * @return array * * @todo remove the override handling once Flow takes care of that, see FLOW-61 */ public function parseXliffToArray($xliffPathAndFilename, $packageKey, $sourceName) { /** @var array $parsedData */ $parsedData = $this->xliffParser->getParsedData($xliffPathAndFilename); $arrayData = array(); foreach ($parsedData['translationUnits'] as $key => $value) { $valueToStore = !empty($value[0]['target']) ? $value[0]['target'] : $value[0]['source']; if ($this->scrambleTranslatedLabels) { $valueToStore = str_repeat('#', UnicodeFunctions::strlen($valueToStore)); } $this->setArrayDataValue($arrayData, str_replace('.', '_', $packageKey) . '.' . str_replace('/', '_', $sourceName) . '.' . str_replace('.', '_', $key), $valueToStore); } return $arrayData; }
/** * @test * @expectedException \Neos\Flow\I18n\Xliff\Exception\InvalidXliffDataException */ public function missingIdInPluralTransUnitCausesException() { $mockFilenamePath = __DIR__ . '/../Fixtures/MockInvalidPluralXliffData.xlf'; $parser = new I18n\Xliff\XliffParser(); $parser->getParsedData($mockFilenamePath); }