Neos\Flow\I18n\TranslationProvider\XliffTranslationProvider::getTranslationByOriginalLabel PHP Метод

getTranslationByOriginalLabel() публичный Метод

Chooses particular form of label if available and defined in $pluralForm.
public getTranslationByOriginalLabel ( string $originalLabel, Locale $locale, string $pluralForm = null, string $sourceName = 'Main', string $packageKey = 'Neos.Flow' ) : mixed
$originalLabel string Label used as a key in order to find translation
$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
Результат mixed Translated label or FALSE on failure
    public function getTranslationByOriginalLabel($originalLabel, 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 (!is_array($pluralFormsForProvidedLocale) || !in_array($pluralForm, $pluralFormsForProvidedLocale)) {
                throw new InvalidPluralFormException('There is no plural form "' . $pluralForm . '" in "' . (string) $locale . '" locale.', 1281033386);
            }
            // 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->getTargetBySource($originalLabel, $pluralFormIndex);
    }