laravel/framework — pull request #1960 by phpmycoder (2013-07-28 00:02:09+00:00)
Title: Fixed Pluralizer capitalization of compound words terminated by an irregular

`Pluralizer` doesn't properly handle compound words (with a capital first letter) that end in an irregular. For example:

str_plural('Freshman') === 'FreshMen'

This works with any word that ends with any of the `Pluralizer::$irregular` words and is a problem in both directions (singular to plural or plural to singular). The cause of this problem is that `Pluralizer::inflect` tries to match the case of the original `$value` by passing it to `Pluralizer::matchCase`. However, since the value in this instance has a capital letter, `matchCase` assumes that `ucfirst` is the correct function to capitalize the irregular substitution. However, the actual part of the word being changed should match `mb_strtolower` (`'man'`).

To fix this bug, I modified `inflect` to only pass to `matchCase` the part of the original `$value` that (with the exception of case) matches the irregular. I also added some unit tests for this case.