diff --git a/src/Illuminate/Support/Pluralizer.php b/src/Illuminate/Support/Pluralizer.php index 9e402f640c69..6cc55ad7b885 100755 --- a/src/Illuminate/Support/Pluralizer.php +++ b/src/Illuminate/Support/Pluralizer.php @@ -6,6 +6,55 @@ class Pluralizer { + /** + * Uncountable word forms. + * + * @var array + */ + public static $uncountable = [ + 'audio', + 'bison', + 'cattle', + 'chassis', + 'compensation', + 'coreopsis', + 'data', + 'deer', + 'education', + 'emoji', + 'equipment', + 'evidence', + 'feedback', + 'firmware', + 'fish', + 'furniture', + 'gold', + 'hardware', + 'information', + 'jedi', + 'kin', + 'knowledge', + 'love', + 'metadata', + 'money', + 'moose', + 'news', + 'nutrition', + 'offspring', + 'plankton', + 'pokemon', + 'police', + 'rain', + 'rice', + 'series', + 'sheep', + 'software', + 'species', + 'swine', + 'traffic', + 'wheat', + ]; + /** * Get the plural form of an English word. * @@ -15,11 +64,13 @@ class Pluralizer */ public static function plural($value, $count = 2) { - if ((int) $count === 1) { + if ((int) $count === 1 || static::uncountable($value)) { return $value; } - return static::matchCase(Inflector::pluralize($value), $value); + $plural = Inflector::pluralize($value); + + return static::matchCase($plural, $value); } /** @@ -35,6 +86,17 @@ public static function singular($value) return static::matchCase($singular, $value); } + /** + * Determine if the given value is uncountable. + * + * @param string $value + * @return bool + */ + protected static function uncountable($value) + { + return in_array(strtolower($value), static::$uncountable); + } + /** * Attempt to match the case on two strings. *