Pluralize or Singularize a string
@param string $string
@param int $pluralize
@return string
10671
public function inflect(string $string, $pluralize = 0) : string
    {
        return ($pluralize) ? Inflect::pluralize($string) : Inflect::singularize($string);
    }
1281029
public static function pluralise($iValue, $sSingular, $sSpecified = null)
    {
        $sSingular = trim($sSingular);

        if ($iValue == 1) {
            return $sSingular;
        } else {
            return $sSpecified ?: plural($sSingular);
        }
    }
15862
public static function studlyCase($string) {
    $string = Strings::capitalize(Strings::replace($string, ['/-/', '/_/'], ' '));
    return Strings::replace($string, '/ /');
  }
1363110
public function plural($key, $count, array $vars = [])
    {
        if ($count === 1) {
            return $this->singular($key, $vars);
        }

        return $this->singular($key . '_plural', ['count' => $count] + $vars);
    }
172787
public static function pluralize($word) {
        foreach(self::$_exceptions as $exception) {
			if($exception['singular'] == $word){
				return $exception['plural'];
			}
        }

        return parent::pluralize($word);
	}
849599
public static function pluralize(string $noun, ?int $count = null): string
	{
		if($count !== 1)
		{
			if(isset(static::$irregulars[$noun]))
			{
				$noun = static::$irregulars[$noun];
			}
			else
			{
				foreach(static::$pluralizationRules as $search => $replace)
				{
					if(preg_match($search, $noun))
					{
						$noun = preg_replace($search, $replace, $noun);

						break;
					}
				}
			}
		}

		return $noun;
	}
251258
public static function pluralize($string) {
        $string = trim($string);
        $testString = strtolower($string);
        if($testString == '') {
            return '';
        } elseif(substr($testString, -3) == 'day') {
            return $string.'s';
        } elseif(substr($testString, -2) == 'ch') {
            return $string.'es';
        } elseif(substr($testString, -1) == 'x') {
            return $string.'es';
        } elseif(substr($testString, -1) == 'y') {
            return substr($string, 0, -1).'ies';
        } else {
            return $string.'s';
        }
    }
1282599
public static function singularize(string $word): string
	{
		if (isset(static::$_cache['singularize'][$word])) {
			return static::$_cache['singularize'][$word];
		}

		if (!isset(static::$_cache['irregular']['singular'])) {
			static::$_cache['irregular']['singular'] = '(?:' . \implode('|', static::$_irregular) . ')';
		}

		if (\preg_match('/(.*?(?:\\b|_))(' . static::$_cache['irregular']['singular'] . ')$/i', $word, $regs)) {
			static::$_cache['singularize'][$word] = $regs[1] . $regs[2][0] .
				\substr(\array_search(\strtolower($regs[2]), static::$_irregular, true), 1);

			return static::$_cache['singularize'][$word];
		}

		if (!isset(static::$_cache['uninflected'])) {
			static::$_cache['uninflected'] = '(?:' . \implode('|', static::$_uninflected) . ')';
		}

		if (\preg_match('/^(' . static::$_cache['uninflected'] . ')$/i', $word, $regs)) {
			static::$_cache['pluralize'][$word] = $word;

			return $word;
		}

		foreach (static::$_singular as $rule => $replacement) {
			if (\preg_match($rule, $word)) {
				static::$_cache['singularize'][$word] = \preg_replace($rule, $replacement, $word);

				return static::$_cache['singularize'][$word];
			}
		}
		static::$_cache['singularize'][$word] = $word;

		return $word;
	}
1035039
public static function idize($string, $capitalize = false)
    {
        $string = mb_strtolower(static::stripDiacritics($string));

        $string = preg_replace('/[^0-9a-zA-Z-]/i', '-', $string);
        $string = preg_replace('/(-+)/i', '-', $string);
        $string = trim($string, '-');

        return $capitalize ? mb_strtoupper($string) : $string;
    }
367707
public static function pluralize($word)
    {
        if (isset(self::$_cache['pluralize'][$word])) {
            return self::$_cache['pluralize'][$word];
        }

        if (!isset(self::$_plural['merged']['irregular'])) {
            self::$_plural['merged']['irregular'] = self::$_plural['irregular'];
        }

        if (!isset(self::$_plural['merged']['uninflected'])) {
            self::$_plural['merged']['uninflected'] = array_merge(self::$_plural['uninflected'], self::$_uninflected);
        }

        if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) {
            self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')';
            self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')';
        }

        if (preg_match('/(.*)\\b(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
            self::$_cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1);
            return self::$_cache['pluralize'][$word];
        }

        if (preg_match('/^(' . self::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) {
            self::$_cache['pluralize'][$word] = $word;
            return $word;
        }

        foreach (self::$_plural['rules'] as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                self::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
                return self::$_cache['pluralize'][$word];
            }
        }
    }
987648
public static function encode_plurals($plurals)
    {
        // Validate against global plural list
        $forms = i18n::config()->uninherited('plurals');
        $forms = array_combine($forms, $forms);
        $intersect = array_intersect_key($plurals, $forms);
        if ($intersect) {
            return implode('|', $intersect);
        }
        return null;
    }
165265
protected function pluralize($strName)
    {
        // Special Rules go Here
        switch (true) {
            case (strtolower($strName) == 'play'):
                return $strName . 's';
        }

        $intLength = strlen($strName);
        if (substr($strName, $intLength - 1) == "y") {
            return substr($strName, 0, $intLength - 1) . "ies";
        }
        if (substr($strName, $intLength - 1) == "s") {
            return $strName . "es";
        }
        if (substr($strName, $intLength - 1) == "x") {
            return $strName . "es";
        }
        if (substr($strName, $intLength - 1) == "z") {
            return $strName . "zes";
        }
        if (substr($strName, $intLength - 2) == "sh") {
            return $strName . "es";
        }
        if (substr($strName, $intLength - 2) == "ch") {
            return $strName . "es";
        }

        return $strName . "s";
    }
771201
public function pluralize()
    {
        if($this->getParameter('upperCaseFirst') == 'true')
            return ucfirst(StringUtils::pluralize($this->getParameter('value')));

        return StringUtils::pluralize($this->getParameter('value'));
    }
748681
public static function singularize($word) {
		if (isset(self::$_cache['singularize'][$word])) {
			return self::$_cache['singularize'][$word];
		}

		if (!isset(self::$_singular['merged']['uninflected'])) {
			self::$_singular['merged']['uninflected'] = array_merge(
				self::$_singular['uninflected'],
				self::$_uninflected
			);
		}

		if (!isset(self::$_singular['merged']['irregular'])) {
			self::$_singular['merged']['irregular'] = array_merge(
				self::$_singular['irregular'],
				array_flip(self::$_plural['irregular'])
			);
		}

		if (!isset(self::$_singular['cacheUninflected']) || !isset(self::$_singular['cacheIrregular'])) {
			self::$_singular['cacheUninflected'] = '(?:' . join('|', self::$_singular['merged']['uninflected']) . ')';
			self::$_singular['cacheIrregular'] = '(?:' . join('|', array_keys(self::$_singular['merged']['irregular'])) . ')';
		}

		if (preg_match('/(.*)\\b(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) {
			self::$_cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1);
			return self::$_cache['singularize'][$word];
		}

		if (preg_match('/^(' . self::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) {
			self::$_cache['singularize'][$word] = $word;
			return $word;
		}

		foreach (self::$_singular['rules'] as $rule => $replacement) {
			if (preg_match($rule, $word)) {
				self::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word);
				return self::$_cache['singularize'][$word];
			}
		}
		self::$_cache['singularize'][$word] = $word;
		return $word;
	}
78732
protected function parseTags(string $string): string
	{
		if(stripos($string, '</pluralize>') !== false)
		{
			$string = $this->parsePluralizationTags($string);
		}

		if(stripos($string, '</number>') !== false)
		{
			$string = $this->parseNumberTags($string);
		}

		return $string;
	}
1372736
public static function plural($string)
	{
		//assign the input string to a result variable
		$result = $string;

		//loop through the array of plural patterns, getting the regular exppression friendly pattern
		foreach (self::$plurals as $rule => $replacement) 
		{
			//get the regular axpression friendlt pattern
			$result = $string;

			//check if there is a match for this pattern in the input string
			if ( preg_match($rule, $string) ) 
			{
				//if match found, replace rule with the replacement string
				$result = preg_replace($rule, $replacement, $string);

				//break out of loop once match is found
				break;

			}

		}

		//return the new string contained in result
		return $result;

	}
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;
    }