Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
LICENSE | H A D | 03-Jun-2019 | 1 KiB | |||
README.md | H A D | 03-Jun-2019 | 1.7 KiB | |||
go.mod | H A D | 03-Jun-2019 | 36 | |||
inflections.go | H A D | 03-Jun-2019 | 8 KiB | |||
inflections_test.go | H A D | 03-Jun-2019 | 5.6 KiB | |||
wercker.yml | H A D | 03-Jun-2019 | 354 |
README.md
1# Inflection 2 3Inflection 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 10inflection.Plural("person") => "people" 11inflection.Plural("Person") => "People" 12inflection.Plural("PERSON") => "PEOPLE" 13inflection.Plural("bus") => "buses" 14inflection.Plural("BUS") => "BUSES" 15inflection.Plural("Bus") => "Buses" 16 17inflection.Singular("people") => "person" 18inflection.Singular("People") => "Person" 19inflection.Singular("PEOPLE") => "PERSON" 20inflection.Singular("buses") => "bus" 21inflection.Singular("BUSES") => "BUS" 22inflection.Singular("Buses") => "Bus" 23 24inflection.Plural("FancyPerson") => "FancyPeople" 25inflection.Singular("FancyPeople") => "FancyPerson" 26``` 27 28## Register Rules 29 30Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb) 31 32If you want to register more rules, follow: 33 34``` 35inflection.AddUncountable("fish") 36inflection.AddIrregular("person", "people") 37inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses" 38inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS" 39``` 40 41## Contributing 42 43You 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 55Released under the [MIT License](http://www.opensource.org/licenses/MIT). 56