Support the ongoing development of Laravel.io →
Configuration

Hello! 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!

Last updated 3 years ago.
0

Hi Ricardo,

Here how to pluralize or singularize irregular strings (based on old Laravel 4 issue #2101) for Laravel 4:

<?php
// Fails:
// echo str_plural('bureau');// → 'bureaus'

$newIrregular = ['bureau' => 'bureaux'];
$oldIrregular = \Illuminate\Support\Pluralizer::$irregular;
\Illuminate\Support\Pluralizer::$irregular = array_merge($oldIrregular, $newIrregular);

// Success:
echo str_plural('bureau');// → 'bureaux'

Cheers, Tortue Torche

Last updated 8 years ago.
0

And here how to pluralize or singularize irregular strings for Laravel 5:

// Fails:
// echo str_plural('bureau');// → 'bureaus'

$newIrregularRules = ['bureau' => 'bureaux'];
\Doctrine\Common\Inflector\Inflector::rules('plural', [
    'irregular' => $newIrregularRules
]);

// Success:
echo str_plural('bureau');// → 'bureaux'
Last updated 8 years ago.
0

I think this topic can be marked as solved.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.