public function getTargetByTransUnitId($transUnitId, $pluralFormIndex = 0)
{
if (!isset($this->xmlParsedData['translationUnits'][$transUnitId])) {
$this->i18nLogger->log('No trans-unit element with the id "' . $transUnitId . '" was found in ' . $this->sourcePath . '. Either this translation has been removed or the id in the code or template referring to the translation is wrong.', LOG_DEBUG);
return false;
}
if (!isset($this->xmlParsedData['translationUnits'][$transUnitId][$pluralFormIndex])) {
$this->i18nLogger->log('The plural form index "' . $pluralFormIndex . '" for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->sourcePath . ' is not available.', LOG_DEBUG);
return false;
}
if ($this->xmlParsedData['translationUnits'][$transUnitId][$pluralFormIndex]['target']) {
return $this->xmlParsedData['translationUnits'][$transUnitId][$pluralFormIndex]['target'];
} elseif ($this->locale->getLanguage() === $this->xmlParsedData['sourceLocale']->getLanguage()) {
return $this->xmlParsedData['translationUnits'][$transUnitId][$pluralFormIndex]['source'] ?: false;
} else {
$this->i18nLogger->log('The target translation was empty and the source translation language (' . $this->xmlParsedData['sourceLocale']->getLanguage() . ') does not match the current locale (' . $this->locale->getLanguage() . ') for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->sourcePath, LOG_DEBUG);
return false;
}
}