Search code examples
c#cpu-wordpluralizesingularhumanizer

Humanizer fails to singularize or pluralize an italian word in C#


I have managed to singularize/pluralize an English word using Humanizer, but when I set the CultureInfo to Italian, it just adds an extra 's' to the word.

For example:

"Man".Pluralize() => "Men" ----- correct, It works as expected

"Spaghetto".Pluralize() => "Spaghettos" ----- wrong, It should be "Spaghetti"

I'm afraid it can't find the italian package Humanizer.Core.it, even though I have correctly installed everything!

Is this a bug or am I missing out something? If not, should I be writing my own set of rules and dictionary or is there another library I can use?

I'm currently working with .NET 4.x .

Thank you in advance, cheers!


Solution

  • You will come across words from time to time that do this, and you can of course just add to your own dictionary for Humanizer.

    Declare this on your page.

    using Humanizer.Inflections;
    

    Then add your custom word to the vocabulary.

    Vocabularies.Default.AddPlural("Spaghetto", "Spaghetti");
    

    From here you can use the Pluralise on Spaghetto as much as you want, knowing you will always get Spaghetti.

    Humanizer documentation for adding vocabulary found here: https://github.com/Humanizr/Humanizer#adding-words