Neos\Flow\I18n\TranslationProvider\XliffTranslationProvider::getTranslationById PHP Method

getTranslationById() public method

Chooses particular form of label if available and defined in $pluralForm.
public getTranslationById ( string $labelId, Locale $locale, string $pluralForm = null, string $sourceName = 'Main', string $packageKey = 'Neos.Flow' ) : mixed
$labelId string Key used to find translated label
$locale Neos\Flow\I18n\Locale Locale to use
$pluralForm string One of RULE constants of PluralsReader
$sourceName string A relative path to the filename with translations (labels' catalog)
$packageKey string Key of the package containing the source file
return mixed Translated label or FALSE on failure
    public function getTranslationById($labelId, I18n\Locale $locale, $pluralForm = null, $sourceName = 'Main', $packageKey = 'Neos.Flow')
    {
        $model = $this->getModel($packageKey, $sourceName, $locale);
        if ($pluralForm !== null) {
            $pluralFormsForProvidedLocale = $this->pluralsReader->getPluralForms($locale);
            if (!in_array($pluralForm, $pluralFormsForProvidedLocale)) {
                throw new InvalidPluralFormException('There is no plural form "' . $pluralForm . '" in "' . (string) $locale . '" locale.', 1281033387);
            }
            // We need to convert plural form's string to index, as they are accessed using integers in XLIFF files
            $pluralFormIndex = (int) array_search($pluralForm, $pluralFormsForProvidedLocale);
        } else {
            $pluralFormIndex = 0;
        }
        return $model->getTargetByTransUnitId($labelId, $pluralFormIndex);
    }