/** * Returns translated label ("target" tag in XLIFF) for the id given. * Id is compared with "id" attribute of "trans-unit" tag (see XLIFF * specification for details). * * @param string $transUnitId The "id" attribute of "trans-unit" tag in XLIFF * @param integer $pluralFormIndex Index of plural form to use (starts with 0) * @return mixed Translated label or FALSE on failure */ public function getTargetByTransUnitId($transUnitId, $pluralFormIndex = 0) { if (!isset($this->xmlParsedData['translationUnits'][$transUnitId])) { $this->systemLogger->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_WARNING); return FALSE; } if (!isset($this->xmlParsedData['translationUnits'][$transUnitId][$pluralFormIndex])) { $this->systemLogger->log('The plural form index "' . $pluralFormIndex . '" for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->sourcePath . ' is not available.', LOG_WARNING); 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->systemLogger->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_WARNING); return FALSE; } }
/** * Returns array of plural forms available for particular locale. * * @param \TYPO3\FLOW3\I18n\Locale $locale Locale to return plural forms for * @return array Plural forms' names (one, zero, two, few, many, other) available for language set in this model */ public function getPluralForms(\TYPO3\FLOW3\I18n\Locale $locale) { if (!isset($this->rulesetsIndices[$locale->getLanguage()])) { return array(self::RULE_OTHER); } return array_merge(array_keys($this->rulesets[$locale->getLanguage()][$this->rulesetsIndices[$locale->getLanguage()]]), array(self::RULE_OTHER)); }