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

4

In a C # application I want to pluralize a few words in Portuguese. But apparently there is no native support for pt-BR.

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

When you execute this method, the following exception is thrown.:

  

The 'Portuguese (Brazil) culture' is not supported. Currently, pluralization is only supported in the English language.

Is there any way to add this support in pt-br?

    
asked by anonymous 15.07.2016 / 18:50

1 answer

8

I think your question is related to this question. As the answer contained in it, when the exception that you're getting show that there is nothing for that purpose until now.

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

  

Install-Package PluralizationServices

Once you've done that, just use it.

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

It has some minor problems, such as accented words (eg bread rolls), but you might consider helping out the project by official github project < a>.

    
15.07.2016 / 19:28