Correcting order of inflection rules in pluralize(). Places uninflected rules before irregular rules. Fixes compatibility with non-english languages. Fixes #6351

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8169 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2009-05-08 03:17:26 +00:00
parent 029f422953
commit 109bda97b8

View file

@ -249,16 +249,16 @@ class Inflector extends Object {
$_this->pluralRules['regexIrregular'] = $regexIrregular; $_this->pluralRules['regexIrregular'] = $regexIrregular;
} }
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->pluralized[$word];
}
if (preg_match('/^(' . $regexUninflected . ')$/i', $word, $regs)) { if (preg_match('/^(' . $regexUninflected . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $word; $_this->pluralized[$word] = $word;
return $word; return $word;
} }
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->pluralized[$word];
}
foreach ($pluralRules as $rule => $replacement) { foreach ($pluralRules as $rule => $replacement) {
if (preg_match($rule, $word)) { if (preg_match($rule, $word)) {
$_this->pluralized[$word] = preg_replace($rule, $replacement, $word); $_this->pluralized[$word] = preg_replace($rule, $replacement, $word);