README.md (1708B)
1 # Inflection 2 3 Inflection pluralizes and singularizes English nouns 4 5 [![wercker status](https://app.wercker.com/status/f8c7432b097d1f4ce636879670be0930/s/master "wercker status")](https://app.wercker.com/project/byKey/f8c7432b097d1f4ce636879670be0930) 6 7 ## Basic Usage 8 9 ```go 10 inflection.Plural("person") => "people" 11 inflection.Plural("Person") => "People" 12 inflection.Plural("PERSON") => "PEOPLE" 13 inflection.Plural("bus") => "buses" 14 inflection.Plural("BUS") => "BUSES" 15 inflection.Plural("Bus") => "Buses" 16 17 inflection.Singular("people") => "person" 18 inflection.Singular("People") => "Person" 19 inflection.Singular("PEOPLE") => "PERSON" 20 inflection.Singular("buses") => "bus" 21 inflection.Singular("BUSES") => "BUS" 22 inflection.Singular("Buses") => "Bus" 23 24 inflection.Plural("FancyPerson") => "FancyPeople" 25 inflection.Singular("FancyPeople") => "FancyPerson" 26 ``` 27 28 ## Register Rules 29 30 Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb) 31 32 If you want to register more rules, follow: 33 34 ``` 35 inflection.AddUncountable("fish") 36 inflection.AddIrregular("person", "people") 37 inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses" 38 inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS" 39 ``` 40 41 ## Contributing 42 43 You can help to make the project better, check out [http://gorm.io/contribute.html](http://gorm.io/contribute.html) for things you can do. 44 45 ## Author 46 47 **jinzhu** 48 49 * <http://github.com/jinzhu> 50 * <wosmvp@gmail.com> 51 * <http://twitter.com/zhangjinzhu> 52 53 ## License 54 55 Released under the [MIT License](http://www.opensource.org/licenses/MIT).