Determines which replacement to use for plurals.

@param integer $numeral

@return integer
767596
public function calculateNumeral($numeral)
    {
        // Use custom enumerator
        if ($this->enumerator) {
            return $this->enumerator($numeral);
        }

        return ($numeral > 1 or $numeral < -1 or $numeral == 0) ? 1 : 0;
    }
927712
public function shortenNumber($number)
    {
        $abbr = [9 => 'B', 6 => 'M', 3 => 'K'];

        foreach ($abbr as $exponent => $suffix) {
            if ($number >= pow(10, $exponent)) {
                return intval($number / pow(10, $exponent)) . $suffix;
            }
        }

        return $number;
    }
1010787
protected function pluralize($word)
    {
        $result = strval($word);

        if (in_array(strtolower($result), $this->uncountableWords())) {
            return $result;
        } else {
            foreach ($this->pluralRules() as $rule => $replacement) {
                if (preg_match($rule, $result)) {
                    $result = preg_replace($rule, $replacement, $result);
                    break;
                }
            }

            return $result;
        }
    }
150823
public function singularize(string $word, int $number = 1): string
    {
        return abs($number) === 1 ? Inflector::singularize($word) : $word;
    }
988138
public function numberToRomanNumerals(int $number): string
    {
        if ($number < 1) {
            // Cannot convert zero/negative numbers
            return (string) $number;
        }
        $roman = '';
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while ($number >= $key) {
                $roman  .= $value;
                $number -= $key;
            }
        }

        return $roman;
    }
309784
public function plural($string, $count = 1)
    {
        $localise = $this->getLocalise($this->locale);

        // Get language plural handles
        $suffix = $localise->getPluralSuffix((int) $count);

        if ($suffix || $suffix == 0) {
            $key = $string . '_' . $suffix;

            if ($this->exists($key)) {
                $string = $key;
            }
        }

        // If current locale do not have singular & plural string
        // We try to do same thing to default locale
        if (!$this->exists($string)) {
            // Find default localise
            $localise = $this->getLocalise($this->defaultLocale);

            // Get language plural handles
            $suffix = $localise->getPluralSuffix((int) $count);

            if ($suffix || $suffix == 0) {
                $key = $string . '_' . $suffix;

                if ($this->exists($key)) {
                    $string = $key;
                }
            }
        }

        // If more arguments exists, use sprintf()
        $args = func_get_args();

        unset($args[1]);

        if (count($args) > 1) {
            $args[0] = $string;

            $offset = $this->traceLevelOffset = $this->traceLevelOffset + 2;

            $result = call_user_func_array([$this, 'sprintf'], $args);

            $this->traceLevelOffset = $offset;

            return $result;
        }

        // Fallback to default translate
        $offset = $this->traceLevelOffset++;

        $result = $this->translate($string);

        $this->traceLevelOffset = $offset;

        return $result;
    }
294754
public static function spellNumber($number)
    {
        $a = new \NumberFormatter(Yii::$app->language, \NumberFormatter::SPELLOUT);

        return $a->format($number);
    }
668872
public function getPluralSuffixes($count)
	{
		if ($this->callbacks['pluralSuffixes'] !== null)
		{
			return call_user_func($this->callbacks['pluralSuffixes'], $count);
		}
		else
		{
			return array((string) $count);
		}
	}
771201
public function pluralize()
    {
        if($this->getParameter('upperCaseFirst') == 'true')
            return ucfirst(StringUtils::pluralize($this->getParameter('value')));

        return StringUtils::pluralize($this->getParameter('value'));
    }
935364
public static function pluralize($word)
    {
        //Get the cached noun of it exists
        if(isset(self::$_cache['pluralized'][$word])) {
            return self::$_cache['pluralized'][$word];
        }

        //Create the plural noun
        if (in_array($word, self::$_rules['countable'])) {
            self::$_cache['pluralized'][$word] = $word;
            return $word;
        }

        foreach (self::$_rules['pluralization'] as $regexp => $replacement)
        {
            $matches = null;
            $plural = preg_replace($regexp, $replacement, $word, -1, $matches);
            if ($matches > 0) {
                self::$_cache['pluralized'][$word] = $plural;
                return $plural;
            }
        }

        return $word;
    }
15096
public static function pluralize($string) {
        $g11n = G11n::registry();

        if (!$g11n->isEnabled()) {
            return $string;
        }

        return static::cache([__METHOD__, $string], function() use ($string, $g11n) {
            $string = mb_strtolower($string);
            $result = null;
            $inflections = $g11n->current()->getInflectionRules();

            if (!$inflections) {
                return $string;

            } else if (!empty($inflections['uninflected']) && in_array($string, $inflections['uninflected'])) {
                $result = $string;

            } else if (!empty($inflections['irregular']) && isset($inflections['irregular'][$string])) {
                $result = $inflections['irregular'][$string];

            } else if (!empty($inflections['irregular']) && in_array($string, $inflections['irregular'])) {
                $result = $string;

            } else if (!empty($inflections['plural'])) {
                foreach ($inflections['plural'] as $pattern => $replacement) {
                    if (preg_match($pattern, $string)) {
                        $result = preg_replace($pattern, $replacement, $string);
                        break;
                    }
                }
            }

            if (empty($result)) {
                $result = $string;
            }

            return $result;
        });
    }
1145515
public static function plural($count, $single, $plural = null)
	{
		if (\is_null($plural)) {
			$plural = $single.'s';
		}
		return $count == 1
			? $single
			: $plural;
	}
123476
public function getPluralSuffixes($count)
	{
		if ($this->pluralSuffixesCallback !== null)
		{
			return call_user_func($this->pluralSuffixesCallback, $count);
		}
		else
		{
			return array((string) $count);
		}
	}
1102111
public static function plural($value, $count = 2)
	{
		if ($count == 1) return $value;

		// First we'll check the cache of inflected values. We cache each word that
		// is inflected so we don't have to spin through the regular expressions
		// on each subsequent method calls for this word by the app developer.
		if (isset(static::$pluralCache[$value]))
		{
			return static::$pluralCache[$value];
		}

		$irregular = array_flip(static::$irregular);

		// When doing the singular to plural transformation, we'll flip the irregular
		// array since we need to swap sides on the keys and values. After we have
		// the transformed value we will cache it in memory for faster look-ups.
		$plural = static::$plural;

		$result = static::inflect($value, $plural, $irregular);

		return static::$pluralCache[$value] = $result;
	}
1363110
public function plural($key, $count, array $vars = [])
    {
        if ($count === 1) {
            return $this->singular($key, $vars);
        }

        return $this->singular($key . '_plural', ['count' => $count] + $vars);
    }
626526
public function plural($value, $count = 2)
        {
            if ((int) $count == 1) return $value;

            // First we'll check the cache of inflected values. We cache each word that
            // is inflected so we don't have to spin through the regular expressions
            // each time we need to inflect a given value for the developer.
            if (isset($this->plural[$value])) {
                return $this->plural[$value];
            }

            // English words may be automatically inflected using regular expressions.
            // If the word is English, we'll just pass off the word to the automatic
            // inflection method and return the result, which is cached.
            $irregular = array_flip($this->config['irregular']);

            $result = $this->auto($value, $this->config['plural'], $irregular);

            return $this->plural[$value] = $result;
        }
702414
protected function plural_rules($lang)
	{
		if ( ! isset($this->_rules[$lang]))
		{
			// Get language code prefix
			$parts = explode('-', $lang, 2);
			$this->_rules[$lang] = $this->plural_rules_factory()
				->create_rules($parts[0]);
		}
		return $this->_rules[$lang];
	}