Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

[SOLVED] Problem with singular / plural rule

posted by jmtucu 7 years ago

Hello! I've a problem when trying to use the ->build() method in a object. Here's an example

$emp -> new Empleado(2);
$fami = $emp->buildFamiliarEmpleados(); # error here because the function it's called buildFamiliarEmpleadoes
var_dump($emp->reflect()); # In here I find the "Empleadoes"

As you can see, there's a problem with the singular expression in my language. Flourish create a function called buildFamiliarEmpleadoes when it must be buildFamiliarEmpleados. That's OK because Flourish talk in English and I in Spanish, but I can't fix the method using fGrammar...

In my source I've

fORM::mapClassToTable('FamiliarEmpleado', 'familiares_empleados'); # Works fine with the DB

And try with fGrammar to fix the name of that method but without lucky

fGrammar::addSingularPluralRule('FamiliarEmpleado', 'FamiliarEmpleados');
echo fGrammar::pluralize('FamiliarEmpleado'); # This return FamiliarEmpleadoes! Why!?

Thanks in advanced!

EDIT: mark as solved.

Try omitting the Familiar from FamiliarEmpleado like this:

fGrammar::addSingularPluralRule('Empleado', 'Empleados');
posted by mblarsen 7 years ago

Thanks mblarsen, that works like a charm!

Apparently fGrammar split the words in camelCase format, good to know.

posted by jmtucu 7 years ago

I think this is true of any "word separation conventions" in Flourish whether it's UpperCamelCase, lowerCamelCase, or under_score_ized (yes, that last one is not separate words, haha). The short of it is, though, only the last word will ever matter in pluralization/singularization.

posted by mattsah 7 years ago