Returns array of plural forms available for particular locale.
public getPluralForms ( |
||
$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 |
/** * Returns label for a key ($labelId) from a file defined by $sourceName. * * Chooses particular form of label if available and defined in $pluralForm. * * @param string $labelId Key used to find translated label * @param I18n\Locale $locale Locale to use * @param string $pluralForm One of RULE constants of PluralsReader * @param string $sourceName A relative path to the filename with translations (labels' catalog) * @param string $packageKey Key of the package containing the source file * @return mixed Translated label or FALSE on failure * @throws InvalidPluralFormException */ 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); }