- Notifications
You must be signed in to change notification settings - Fork20
📘 Pluralize or singularize any English word.
License
sarathkcm/Pluralize.NET
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a C# port of Blake Embrey'spluralize library which helps in pluralizing or singularizing any English word.
Changes reflect commits up tohttps://github.com/blakeembrey/pluralize/commit/0265e4d131ecad8e11c420fa4be98b75dc92c33d from May 25, 2019.
I could not find a good C# alternative for converting words from singular to plural and vice versa.System.Data.Entity.Design.PluralizationServices.PluralizationService andHumanizer library did not meet the expectations (try 'shoes' or 'toes'). However this small but awesome Javascript libraypluralize worked very well for me and I decided to convert the code to C# and use it.
Install from NuGet
Using Package manager console
Install-Package Pluralize.NETUsing dotnet CLI
dotnet add package Pluralize.NETUsing paket CLI
paket add Pluralize.NETInclude using directive
usingPluralize.NET
Write code
IPluralizepluralizer=newPluralizer();pluralizer.Singularize("Horses");//=> "Horse"pluralizer.Pluralize("Horse");//=> "Horses"// Example of new plural rule:pluralizer.Pluralize("regex");//=> "regexes"pluralizer.AddPluralRule(newRegex("gex$"),"gexii");pluralizer.Pluralize("regex");//=> "regexii"// Example of new singular rule:pluralizer.Singularize('singles');//=> "single"pluralizer.AddSingularRule(newRegex("singles"),'singular');pluralizer.Singularize('singles');//=> "singular"// Example of new irregular rule, e.g. "I" -> "we":pluralizer.Pluralize('irregular');//=> "irregulars"pluralizer.AddIrregularRule('irregular','regular');pluralizer.Pluralize('irregular');//=> "regular"// Example of uncountable rule (rules without singular/plural in context):pluralizer.Pluralize('paper');//=> "papers"pluralizer.AddUncountableRule('paper');pluralizer.Pluralize('paper');//=> "paper"// Example of asking whether a word looks singular or plural:pluralizer.IsPlural('test');//=> falsepluralizer.IsSingular('test');//=> true// Example of formatting a word based on countpluralizer.Format(5,"dog");// => "dogs"pluralizer.Format(5,"dog",inclusive:true);// => "5 dogs"
Profit!
The Nuget package supports the following .NET versions. This pretty much covers versions 4.0 and above. Please open an issue if you want to support any .NET version in particular.
- .NET 4.0
- .NET Standard 1.1
- .NET 4.5.1
- .NET 4.6
- .NET Standard 2.0
MIT - because the original project is MIT
Sarath Kumar CM 💻 | Daniel Destouche 💻 | Dennis Pražák 💻 |
This project follows theall-contributors specification. Contributions of any kind welcome!
About
📘 Pluralize or singularize any English word.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.