Documentation ¶
Overview ¶
Package inflection pluralizes and singularizes English nouns.
inflection.Plural("person") => "people" inflection.Plural("Person") => "People" inflection.Plural("PERSON") => "PEOPLE" inflection.Singularize("people") => "person" inflection.Singularize("People") => "Person" inflection.Singularize("PEOPLE") => "PERSON" inflection.Plural("FancyPerson") => "FancydPeople" inflection.Singularize("FancyPeople") => "FancydPerson"
Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb)
If you want to register more rules, follow:
inflection.AddUncountable("fish") inflection.AddIrregular("person", "people") inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses" inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddIrregular ¶
func AddIrregular(key, value string)
func AddSingular ¶
func AddSingular(key, value string)
func AddUncountable ¶
func AddUncountable(value string)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.