Library for managing plurals of nouns or unit expressions ("hours", "meters", and so on).

Supported languages (core library) : English, German, Italian, Spanish, French, Russian, Ukrainian, Belarusian.

Didn't find your language of choice? Make a request.

Using common units pluralizer:

Supported units: date and time (more will be added by request)

Installation:

PM> Install-Package Moveax.Pluralization.Common -IncludePrerelease

Example:

var dtPluralizer = new DateTimePluralizer(new CultureInfo("ru-RU"));
Console.WriteLine("{0} {1}", 1, dtPluralizer.GetStringFor(1, DateTimeUnit.Hours));
Console.WriteLine("{0} {1}", 5, dtPluralizer.GetStringFor(5, DateTimeUnit.Hours));

 Output:
1 час
5 часов

Using your custom nouns and units:

Installation:

PM> Install-Package Moveax.Pluralization.Core -IncludePrerelease

Usage example:

  • Define words in resources according categories from here (you can define multi-language resource)
SomeResource.resx:
CharsOne character
CharsOther characters
SomeResource.ru-RU.resx:
CharsFew символа	
CharsMany символов	
CharsOne символ	
CharsOther символа
  • Add some code: 
int count = new Random().Next(0, 25);

var ruPluralizer = new Pluralizer(new CultureInfo("ru-RU"), new ResourceStringsSource(PhrasesResource.ResourceManager));
units = ruPluralizer.Pluralize("Chars", count);

Console.WriteLine("{0} {1}", count, units);

 Detailed tutorial: http://andrey.moveax.ru/post/moveax-pluralizer-rc-released.aspx

Based on plural rules from http://cldr.unicode.org/

Last edited Jul 5, 2013 at 6:51 AM by AndreyDotNet, version 4