A port of for .NET. The Inflector allows you to determine the plural or singular of a given word, which can be useful for things like code generation. For example:


produces “addresses”. Whereas,


yields “species”;

The code is currently lacking some argument validation and doc comments but all of the tests have been ported and are all passing.

Download the source here: Inflector.NET Download

Let me know if you find any problems.



Leave a response

  1. Thu, 05 Jul 2007 04:25:56 CDT

    Out of curiosity, does Inflector.Net offer any advantages over the Castle Project’s Inflector in ActiveRecord it’s seem very similar, and I wonder if perhaps there’s an opportunity to merge the two at some point?

  2. AndrewNo Gravatar Thu, 05 Jul 2007 04:57:47 CDT

    Hi Alex,

    They are one in the same. After I did the original port I also wrote the pluralization patch for ActiveRecord. :-) I’ll keep it available here in case anyone wants it on it’s own.



  3. Thu, 05 Jul 2007 05:08:47 CDT

    Ahh though they looked pretty similar (well identical, as it turns out heh!)

    Good stuff

  4. Thu, 12 Jul 2007 10:49:36 CDT

    Excellent stuff Andrew.

    I wrote a similar class myself without knowing this one already existed. (probably my class is not covering all the rules inflector has..)

    BTW, is it expected behavior that ApplyRule will return null when no rule matches. Example: calling Pluralize(”Boys”) will return null instead of just returning.

    I’ve added this code to ApplyRules (to match my expected behavior )
    if (result == null) return word;

    I would like to add this class to an existing commercial product, is there any license issue with that?

  5. AndrewNo Gravatar Thu, 12 Jul 2007 19:21:50 CDT

    Your change probably makes sense and feel free to use the code.

  6. ChrisNo Gravatar Mon, 30 Jul 2007 19:03:16 CDT

    “status” doesn’t singularize correctly. Inflector.Singularize(”status”) returns “statu”.

  7. AndrewNo Gravatar Mon, 30 Jul 2007 20:02:49 CDT

    That’s because the plural of status is statuses.

  8. ChrisNo Gravatar Tue, 31 Jul 2007 00:36:09 CDT

    Yea. In my code generator, I pass our table name of “work_item_status” to Inflector.Singularize I get a class named “WorkItemStatu”. We should rename our table to “work_item_statuses” or “status_of_work_items”.

    I was kind of hoping singularizing procedures would ignore words that are already single, but that may be too much accomplish with a simple algorithm.


  9. AndrewNo Gravatar Sat, 04 Aug 2007 22:07:56 CDT

    That should be a straight-forward change. Take a look at how the rules are specified.


  10. Mon, 07 Jan 2008 00:09:50 CST

    Nice work, I do a lot of ActiveRecord code gen, this will come in handy. Thanks!

  11. Sat, 09 Aug 2008 19:38:51 CDT

    [...] and mouse => mice. Fortunately us in the .NET world can take advantage of the functionality with Infector.NET, a port of the Rails Infector by Andrew Peters. Using this I could simply set the value of my label [...]

  12. Tue, 13 Jan 2009 11:06:46 CST

    Thanks for pointing this out on Fluent Nhibernate’s discussion board, now I can drop needing

    .ForTypesThatDeriveFrom(autoMap => { autoMap.WithTable(”Categories”);

    And handle everything with my convention statement

    WithConvention(convention => convention.GetTableName = type => Inflector.Pluralize(type.Name))!

  13. Tue, 13 Jan 2009 11:24:33 CST

    [...] You can download Inflector and it’s source over at Andrew Peter’s blog Inflector.NET. [...]

  14. Sun, 08 Feb 2009 21:32:33 CST

    [...] While developing a codegen tool, I needed Ruby on Rails’ pluralization functionality. Fortunately, I found a port of Rail’s Inflector class at [...]

  15. Thu, 04 Jun 2009 09:25:50 CDT

    Do you have some problem if I copy the implementation in another project ?

  16. AndrewNo Gravatar Fri, 12 Jun 2009 12:22:22 CDT



  17. Sun, 14 Jun 2009 20:11:57 CDT

    Thank you very much Andrew. I just made a port from english to brazilian portuguese and it works like a charm.

  18. AndrewNo Gravatar Fri, 03 Jul 2009 15:54:15 CDT

    You’re welcome

  19. Fri, 03 Jul 2009 15:58:20 CDT

    Ah sorry Andrew
    this is the post about Inflector you reviewed and its implementation in Spanish

  20. Fri, 03 Jul 2009 16:00:42 CDT

    this is the last with some improvements