Changeset 2972
- Timestamp:
- 07/06/2008 06:54:56 PM (5 months ago)
- Files:
-
- 1 modified
-
tags/2.1.3/system/helpers/inflector.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/2.1.3/system/helpers/inflector.php
r2884 r2972 36 36 } 37 37 38 return isset( $uncountables[$str]);38 return isset(self::$uncountable[strtolower($str)]); 39 39 } 40 40 … … 62 62 63 63 // Cache key name 64 $key = $str.$count;64 $key = 'singular_'.$str.$count; 65 65 66 66 if (isset(self::$cache[$key])) … … 80 80 $str = $irregular; 81 81 } 82 elseif (substr($str, -3) === 'ies') 83 { 84 $str = substr($str, 0, strlen($str) - 3).'y'; 85 } 86 elseif (substr($str, -4) === 'sses' OR substr($str, -3) === 'xes') 87 { 88 $str = substr($str, 0, strlen($str) - 2); 82 elseif (preg_match('/[sxz]es$/i', $str) OR preg_match('/[^aeioudgkprt]hes$/i', $str)) 83 { 84 // Remove "es" 85 $str = substr($str, 0, -2); 86 } 87 elseif (preg_match('/[^aeiou]ies$/i', $str)) 88 { 89 // Remove "ies" 90 $str = substr($str, 0, -3).'y'; 89 91 } 90 92 elseif (substr($str, -1) === 's') 91 93 { 94 // Remove "s" 92 95 $str = substr($str, 0, strlen($str) - 1); 93 96 } … … 118 121 119 122 // Cache key name 120 $key = $str.$count;123 $key = 'plural_'.$str.$count; 121 124 122 125 if (isset(self::$cache[$key])) … … 137 140 if (isset(self::$irregular[strtolower($str)])) 138 141 { 139 $str = self::$irregular[$str]; 140 141 if ($low === FALSE) 142 { 143 // Make uppercase 144 $str = strtoupper($str); 145 } 142 $str = self::$irregular[strtolower($str)]; 146 143 } 147 144 elseif (preg_match('/[sxz]$/i', $str) OR preg_match('/[^aeioudgkprt]h$/i', $str)) … … 163 160 164 161 // Set the cache and return 165 return $cache[$key] = $str;162 return self::$cache[$key] = $str; 166 163 } 167 164
