There are a few similar words used in plurals.xml file of CLDR used by this class. Following naming convention is used in the code (a name of corresponding tag from xml file is provided in brackets, if any): - ruleset: a set of plural rules for a locale [pluralRules] - rule: a rule for one of the forms: zero, one, two, few, many [pluralRule] - subrule: one of the conditions of rule. One rule can have many conditions joined with "and" or "or" logical operator.
See also: http://www.unicode.org/reports/tr35/#Language_Plural_Rules
 /**
  * @test
  * @expectedException \Neos\Flow\I18n\TranslationProvider\Exception\InvalidPluralFormException
  */
 public function getTranslationByIdThrowsExceptionWhenInvalidPluralFormProvided()
 {
     $this->mockPluralsReader->expects($this->any())->method('getPluralForms')->with($this->sampleLocale)->will($this->returnValue([I18n\Cldr\Reader\PluralsReader::RULE_ONE, I18n\Cldr\Reader\PluralsReader::RULE_OTHER]));
     $translationProvider = $this->getMockBuilder(I18n\TranslationProvider\XliffTranslationProvider::class)->setMethods(['getModel'])->getMock();
     $translationProvider->injectPluralsReader($this->mockPluralsReader);
     $translationProvider->getTranslationById('bar', $this->sampleLocale, I18n\Cldr\Reader\PluralsReader::RULE_FEW, $this->sampleSourceName, $this->samplePackageKey);
 }
 /**
  * Get the plural form to be used.
  *
  * If $quantity is numeric and non-NULL, the plural form for provided $locale will be
  * chosen according to it.
  *
  * In all other cases, NULL is returned.
  *
  * @param mixed $quantity
  * @param Locale $locale
  * @return string
  */
 protected function getPluralForm($quantity, Locale $locale)
 {
     if (!is_numeric($quantity)) {
         return null;
     } else {
         return $this->pluralsReader->getPluralForm($quantity, $locale);
     }
 }
 /**
  * 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);
 }
 /**
  * @test
  * @dataProvider quantities
  */
 public function returnsCorrectPluralForm($quantity, $pluralForm)
 {
     $locale = new I18n\Locale('mo');
     $result = $this->reader->getPluralForm($quantity, $locale);
     $this->assertEquals($pluralForm, $result);
 }