Reputation: 13
I am just starting with Laravel, and I have a question on how to solve this "the right way".
I have lots of words in spanish that the plural is not simply appending an "s" in the end, for example, the plural for "Especialidad" is "Especialidades", or the plural for "ObraSocial" is "ObrasSociales".
I'm seeing that there is src/Illuminate/Support/Pluralizer.php with an $irregular array. Is the correct way to add that words in this array (I don't think so..), or is there any other place from where I can put all the words that I need to use?
thanks!
Upvotes: 1
Views: 1156
Reputation: 26992
The right way to do it would probably be to make a new class, extending Illuminate/Support/Pluralizer
called something like SpanishPluralizer
and override all $plural
, $singular
, $irregular
and $uncountable
properties to Spanish equivalents.
If you'll be pluralizing only a few strings though, it would be okeish to simply override the $irregular
property.
Upvotes: 2