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
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'
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community