public function getTargetBySource($source, $pluralFormIndex = 0)
{
if (!isset($this->xmlParsedData['translationUnits'])) {
$this->i18nLogger->log(sprintf('No trans-unit elements were found in "%s". This is allowed per specification, but no translation can be applied then.', $this->sourcePath), LOG_DEBUG);
return false;
}
foreach ($this->xmlParsedData['translationUnits'] as $translationUnit) {
// $source is always singular (or only) form, so compare with index 0
if (!isset($translationUnit[0]) || $translationUnit[0]['source'] !== $source) {
continue;
}
if (count($translationUnit) <= $pluralFormIndex) {
$this->i18nLogger->log('The plural form index "' . $pluralFormIndex . '" for the source translation "' . $source . '" in ' . $this->sourcePath . ' is not available.', LOG_DEBUG);
return false;
}
return $translationUnit[$pluralFormIndex]['target'] ?: false;
}
return false;
}