In C#, how to use the pluralize method in Portuguese?

Asked

Viewed 532 times

4

in a C# application I’m looking to pluralize some words in English. But apparently there is no native support for en-BR.

var pluralizador = System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(new System.Globalization.CultureInfo("pt-BR"));

when executing this method, the following exception is thrown.:

There is no support for the 'Portuguese' (Brazil) culture. At the moment, there is only support for pluralization in the English language.

Is there any way to add this support in?

1 answer

8

I believe your doubt is related to this question. As the answer contained in it, when the exception you are receiving shows that there is nothing for that purpose, so far.

However, there is this package that promises to do what you want. To use it, just install via Nuget by the command below:

Install-Package Pluralizationservices

Done this, just use.

        var service = new PortuguesePluralizationService();
        string plural = service.Pluralize("produto");
        string singular = service.Singularize("produtos");

It has some small problems, such as accented words (e.g., breads), but you might consider helping the project by official github of the project.

  • I tested the tool and it works very well. Unfortunately it does not add support for System.Data.Entity.Design for en-BR. But I will now use it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.