Changeset 276
- Timestamp:
- 01/22/07 04:53:53 (5 years ago)
- Files:
-
- 1 modified
-
trunk/trax/vendor/trax/inflector.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/inflector.php
r201 r276 46 46 * 47 47 * Convert a lower-case singular word to plural form. 48 * If $count > 0 then prefixes $word with the $count 49 * 48 50 * @param string $word Word to be pluralized 51 * @param int $count How many of these $words are there 49 52 * @return string Plural of $word 50 53 */ 51 function pluralize($word) { 52 if(!in_array($word, Inflections::$uncountables)) { 53 $original = $word; 54 foreach(Inflections::$plurals as $plural_rule) { 55 $word = preg_replace($plural_rule['rule'], $plural_rule['replacement'], $word); 56 if($original != $word) break; 54 function pluralize($word, $count = 0) { 55 if($count == 0 || $count > 1) { 56 if(!in_array($word, Inflections::$uncountables)) { 57 $original = $word; 58 foreach(Inflections::$plurals as $plural_rule) { 59 $word = preg_replace($plural_rule['rule'], $plural_rule['replacement'], $word); 60 if($original != $word) break; 61 } 57 62 } 58 63 } 59 return $word;64 return ($count >= 1 ? "{$count} {$word}" : $word); 60 65 } 61 66
