diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index 65045f3c9..2f6d4140f 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -177,7 +177,7 @@ class Inflector extends Object { } if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) { - $_this->pluralized[$word] = $regs[1] . $irregular[strtolower($regs[2])]; + $_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1); return $_this->pluralized[$word]; } @@ -316,7 +316,7 @@ class Inflector extends Object { } if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) { - $_this->singularized[$word] = $regs[1] . $irregular[strtolower($regs[2])]; + $_this->singularized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1); return $_this->singularized[$word]; } diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 940b7a744..60978b3a0 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -45,6 +45,10 @@ class InflectorTest extends UnitTestCase { $expected = 'menu'; $this->assertEqual($result, $expected); + $result = $this->inflector->singularize('Menus'); + $expected = 'Menu'; + $this->assertEqual($result, $expected); + $result = $this->inflector->singularize('houses'); $expected = 'house'; $this->assertEqual($result, $expected); @@ -111,6 +115,10 @@ class InflectorTest extends UnitTestCase { $expected = 'menus'; $this->assertEqual($result, $expected); + $result = $this->inflector->pluralize('Menu'); + $expected = 'Menus'; + $this->assertEqual($result, $expected); + $result = $this->inflector->pluralize('quiz'); $expected = 'quizzes'; $this->assertEqual($result, $expected);