Translate a plural message.

@param  string $singular
@param  string $plural
@param  int $number
@param  string $textDomain
@param  string|null $locale
@return string
767488
public function translatePlural(
        $singular,
        $plural,
        $number,
        $textDomain = 'default',
        $locale = null
    )
    {
        $textDomain = $textDomain !== 'default' ? $textDomain : $this->domain();
        $locale = $locale ?: (string) $this->currentLanguage();

        return $this->translationService()->translatePlural($singular, $plural, $number, $textDomain, $locale);
    }
858472
public function toSingular(Pluralizer $pluralizer = null) {
		$pluralizer = $pluralizer ?: new EnglishPluralizer();

		return new Text($pluralizer->getSingularForm($this->string), $this->encoding);
	}
1145515
public static function plural($count, $single, $plural = null)
	{
		if (\is_null($plural)) {
			$plural = $single.'s';
		}
		return $count == 1
			? $single
			: $plural;
	}
862935
public function handle($locale, $translation, $params = null) {
		return preg_replace_callback('~\[([a-z]+)(?:=([a-z0-9_]+))?\](.*?)\[/\1\]~', function($match) use($locale, $params) {
			list($origin, $bbcode, $bbargument, $value) = $match;
			
			// Plural
			if ($bbcode === 'plural') {
				if (empty($bbargument)) {
					throw new NoRequiredParam('Name of the plural number parameter must be specified in the BBCode');
				}
				
				if (! isset($params[$bbargument])) {
					throw new NoRequiredParam('Required parameter "' . $bbargument . '" is absent');
				}
				
				$result = $this->choosePlural($params[$bbargument], $value, $locale);
				
				return $this->handle($locale, $result, $params);
			}
			
			// Recursive BBCodes
			if (preg_match('~\[[a-z]+(?:=[a-z0-9_]+)?\]~', $value)) {
				$value = $this->handle($locale, $value, $params);
			}
			
			// Try the BBCode action callback
			if (isset($this->actions[$bbcode])) {
				return $this->actions[$bbcode]($value, $bbcode, $origin);
			}
			
			// Try the BBCode formatter
			$formatter = $this->getFormattersInitializer()->initialize(ucfirst($bbcode));
			
			$formatterParams = [];

			if (isset($bbargument[0])) {
				$formatterParams['primary'] = $bbargument;
			}

			if (preg_match($this->getParamExpression(), $value, $valueMatch)) {
				$value = trim($valueMatch[1]);

				if ($params === null || ! isset($params[$value])) {
					throw new NoRequiredParam('Required parameter "' . $value . '" is absent');
				}

				$paramPrefix = $value . '.';

				foreach ($params as $paramKey => $paramValue) {
					if (strpos($paramKey, $paramPrefix) === 0) {
						$formatterParams[str_replace($paramPrefix, '', $paramKey)] = $paramValue;
					}
				}

				return $formatter->format($params[$value], $formatterParams, $locale);
			}

			return $formatter->format($value, $formatterParams, $locale);
		}, $translation);
	}
223037
public static function addWord($singular, $plural)
    {
        self::$_cache['pluralized'][$singular]	= $plural;
        self::$_cache['singularized'][$plural] 	= $singular;

        self::$_cache['singularized'][$singular] = $singular;
        self::$_cache['pluralized'][$plural] = $plural;
    }
881854
private function getDefaultParams($singular, $plural, $params)
    {
        $labels = [
            'name'              => _x($plural, LARAPRESS_TEXTDOMAIN),
            'singular_name'     => _x($singular, LARAPRESS_TEXTDOMAIN),
            'search_items'      => __('Search ' . $plural, LARAPRESS_TEXTDOMAIN),
            'all_items'         => __('All ' . $plural, LARAPRESS_TEXTDOMAIN),
            'parent_item'       => __('Parent ' . $singular, LARAPRESS_TEXTDOMAIN),
            'parent_item_colon' => __('Parent ' . $singular . ': ', LARAPRESS_TEXTDOMAIN),
            'edit_item'         => __('Edit ' . $singular, LARAPRESS_TEXTDOMAIN),
            'update_item'       => __('Update ' . $singular, LARAPRESS_TEXTDOMAIN),
            'add_new_item'      => __('Add New ' . $singular, LARAPRESS_TEXTDOMAIN),
            'new_item_name'     => __('New ' . $singular . ' Name', LARAPRESS_TEXTDOMAIN),
            'menu_name'         => __($plural, LARAPRESS_TEXTDOMAIN),
        ];

        return array_merge([
            'label'             => __($plural, LARAPRESS_TEXTDOMAIN),
            'labels'            => $labels,
            'public'            => true,
            'query_var'         => true,
            'hierarchical'      => true,
            'show_ui'           => true,
            'show_admin_column' => true,
            'show_in_nav_menus' => true,
            'show_tagcloud'     => true,
            'rewrite'           => true,
        ], $params);
    }
580559
private function getCachedSingular($plural)
    {
        $plural = Utf8String::strtolower($plural);

        return array_search($plural, $this->cache);
    }
239710
public function make_plural_form_function($nplurals, $expression)
    {
        try {
            $handler = new PluralForms(rtrim($expression, ';'));

            return array($handler, 'get');
        } catch (\Exception $e) {
            // Fall back to default plural-form function.
            return $this->make_plural_form_function(2, 'n != 1');
        }
    }
14568
private function setCache($singular, $plural = null)
	{
		$singular = String::strtolower($singular);

		if ($plural === null)
		{
			$plural = $singular;
		}
		else
		{
			$plural = String::strtolower($plural);
		}

		$this->cache[$singular] = $plural;
	}
3774
private function pluralize($singular)
    {
        if (null === $this->pluralizer) {
            return $singular;
        }

        return call_user_func($this->pluralizer, $singular);
    }
496209
private static function PluralLangGetForm($lang, $n)
    {
        switch ($lang) {
            case 'ach':
            case 'ak':
            case 'am':
            case 'arn':
            case 'br':
            case 'fil':
            case 'fr':
            case 'ln':
            case 'mfe':
            case 'mg':
            case 'mi':
            case 'oc':
            case 'ti':
            case 'tr':
            case 'wa':
                return (int)($n > 1);
            case 'af':
            case 'an':
            case 'ast':
            case 'az':
            case 'bg':
            case 'bn':
            case 'ca':
            case 'da':
            case 'de':
            case 'el':
            case 'en':
            case 'eo':
            case 'es':
            case 'et':
            case 'eu':
            case 'fi':
            case 'fo':
            case 'fur':
            case 'fy':
            case 'gl':
            case 'gu':
            case 'ha':
            case 'he':
            case 'hi':
            case 'hu':
            case 'ia':
            case 'it':
            case 'kn':
            case 'ku':
            case 'lb':
            case 'mai':
            case 'ml':
            case 'mn':
            case 'mr':
            case 'nah':
            case 'nap':
            case 'nb':
            case 'ne':
            case 'nl':
            case 'se':
            case 'nn':
            case 'no':
            case 'nso':
            case 'or':
            case 'ps':
            case 'pa':
            case 'pap':
            case 'pms':
            case 'pt':
            case 'rm':
            case 'sco':
            case 'si':
            case 'so':
            case 'son':
            case 'sq':
            case 'sw':
            case 'sv':
            case 'ta':
            case 'te':
            case 'tk':
            case 'ur':
            case 'yo':
                return (int)($n != 1);
            case 'jv':
                return (int)($n != 0);
            case 'ay':
            case 'bo':
            case 'cgg':
            case 'dz':
            case 'fa':
            case 'hy':
            case 'id':
            case 'ja':
            case 'jbo':
            case 'ka':
            case 'kk':
            case 'km':
            case 'ko':
            case 'ky':
            case 'lo':
            case 'ms':
            case 'sah':
            case 'su':
            case 'tg':
            case 'th':
            case 'tt':
            case 'ug':
            case 'uz':
            case 'vi':
            case 'wo':
            case 'zh':
                return (int)(0);

            case 'be':
            case 'bs':
            case 'hr':
            case 'ru':
            case 'sr':
            case 'uk':
                return (int)($n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2));
            case 'lt':
                return (int)($n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && ($n % 100 < 10 or $n % 100 >= 20) ? 1 : 2));
            case 'lv':
                return (int)($n % 10 == 1 && $n % 100 != 11 ? 0 : ($n != 0 ? 1 : 2));
            case 'mt':
                return (int)($n == 1 ? 0 : ($n == 0 || ($n % 100 > 1 && $n % 100 < 11) ? 1 : (($n % 100 > 10 && $n % 100 < 20) ? 2 : 3)));
            case 'pl':
                return (int)($n == 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2));
            case 'ar':
                return (int)($n == 0 ? 0 : ($n == 1 ? 1 : ($n == 2 ? 2 : ($n % 100 >= 3 && $n % 100 <= 10 ? 3 : ($n % 100 >= 11 ? 4 : 5)))));
            case 'gd':
                return (int)(($n == 1 || $n == 11) ? 0 : (($n == 2 || $n == 12) ? 1 : (($n > 2 && $n < 20) ? 2 : 3)));
            case 'is':
                return (int)($n % 10 != 1 || $n % 100 == 11);

            case 'cs':
            case 'sk':
                return (int)(($n == 1) ? 0 : (($n >= 2 && $n <= 4) ? 1 : 2));
            case 'cy':
                return (int)(($n == 1) ? 0 : (($n == 2) ? 1 : (($n != 8 && $n != 11) ? 2 : 3)));
            case 'ga':
                return (int)(($n == 1) ? 0 : (($n == 2) ? 1 : ($n < 7 ? 2 : ($n < 11 ? 3 : 4))));
            case 'kw':
                return (int)(($n == 1) ? 0 : (($n == 2) ? 1 : (($n == 3) ? 2 : 3)));

            case 'mk':
                return (int)(($n == 1 || $n % 10 == 1) ? 0 : 1);
            case 'mnk':
                return (int)($n == 0 ? 0 : ($n == 1 ? 1 : 2));

            case 'ro':
                return (int)($n == 1 ? 0 : (($n == 0 || ($n % 100 > 0 && $n % 100 < 20)) ? 1 : 2));
            case 'sl':
                return (int)($n % 100 == 1 ? 1 : ($n % 100 == 2 ? 2 : ($n % 100 == 3 || $n % 100 == 4 ? 3 : 0)));
            default:
                return 0;
        }
    }
81233
public function translate($key, array $tokensValues = [])
    {
        if (isset($tokensValues['_count'])) {
            $message = $this->getMessage(static::PLURAL_PREFIX . $key);
            if (!$message) {
                $message = $this->getMessage($key);
            }
        } else {
            $message = $this->getMessage($key);
            if (!$message) {
                $message = $this->getMessage(static::PLURAL_PREFIX . $key);
            }
        }

        if (!$message) {
            // Fallback to the message key
            $message = $key;
        }

        // Check for missing/invalid context
        if (isset($message['_context'])) {
            $message = $this->resolveContext($key, $message, $tokensValues);
            unset($tokensValues['_context']);
        }

        if (!$tokensValues) {
            // Fallback for plurals that were using the singular key
            if (is_array($message)) {
                return array_values($message + [''])[0];
            }

            return $message;
        }

        // Singular message, but plural call
        if (is_string($message) && isset($tokensValues['_singular'])) {
            $message = [$tokensValues['_singular'], $message];
        }

        // Resolve plural form.
        if (is_array($message)) {
            $count = isset($tokensValues['_count']) ? $tokensValues['_count'] : 0;
            $form = PluralRules::calculate($this->locale, $count);
            $message = isset($message[$form]) ? $message[$form] : (string)end($message);
        }

        if (strlen($message) === 0) {
            $message = $key;
        }

        return $this->formatter->format($this->locale, $message, $tokensValues);
    }
571806
protected function inflect(array $plurals, $value, $rdc = null)
    {
        foreach ($plurals as $pattern => $repl) {
            if (preg_match($pattern, $value)) {
                return preg_replace($pattern, $repl, $value);
            }
        }

        return null === $rdc ? $value : (self::REDUCE === $rdc ? $this->reduceVal($value) : $this->appendVal($value));
    }
581640
function ( number, pluralRules ) {
			var i,
				pluralForms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ],
				pluralFormIndex = 0;

			for ( i = 0; i < pluralForms.length; i++ ) {
				if ( pluralRules[pluralForms[i]] ) {
					if ( pluralRuleParser( pluralRules[pluralForms[i]], number ) ) {
						return pluralFormIndex;
					}

					pluralFormIndex++;
				}
			}

			return pluralFormIndex;
		}
183364
public static function pluralize($input) {
		if (self::$pluralizer === null) {
			self::$pluralizer = new StandardEnglishSingularizer();
		}

		return self::$pluralizer->getPluralForm($input);
	}
424868
public function ngettext($singular, $plural, $count) {
		if ($this->reader === null) {
			return $count > 1 ? $plural : $singular;
		}
		return $this->reader->ngettext((string)$singular, (string)$plural, $count);
	}
1128191
public function fixXmlConfig($singular, $plural = null)
    {
        $this->normalization()->remap($singular, $plural);

        return $this;
    }