Commits

Kyle Farris committed d956cf1

Changed the 'plural' function so that it doesn't ruin the captalization of your string. It also take into consideration acronyms which are all caps.

Comments (0)

Files changed (1)

system/helpers/inflector_helper.php

 {
 	function plural($str, $force = FALSE)
 	{
-		$str = strtolower(trim($str));
 		$end = substr($str, -1);
 
-		if ($end == 'y')
+		if (preg_match('/y/i',$end))
 		{
 			// Y preceded by vowel => regular plural
-			$vowels = array('a', 'e', 'i', 'o', 'u');
+			$vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U');
 			$str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
 		}
-		elseif ($end == 'h')
+		elseif (preg_match('/h/i',$end))
 		{
-			if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh')
+            if(preg_match('/^[c|s]h$/i',substr($str, -2)))
 			{
 				$str .= 'es';
 			}
 				$str .= 's';
 			}
 		}
-		elseif ($end == 's')
+		elseif (preg_match('/s/i',$end))
 		{
 			if ($force == TRUE)
 			{