notary: github.com/docker/notary/vendor/github.com/jinzhu/inflection Index | Files

package inflection

import "github.com/docker/notary/vendor/github.com/jinzhu/inflection"

Package inflection pluralizes and singularizes English nouns.

inflection.Plural("person") => "people"
inflection.Plural("Person") => "People"
inflection.Plural("PERSON") => "PEOPLE"

inflection.Singular("people") => "person"
inflection.Singular("People") => "Person"
inflection.Singular("PEOPLE") => "PERSON"

inflection.Plural("FancyPerson") => "FancydPeople"
inflection.Singular("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

Package Files

inflections.go

func AddIrregular Uses

func AddIrregular(singular, plural string)

AddIrregular adds an irregular inflection

func AddPlural Uses

func AddPlural(find, replace string)

AddPlural adds a plural inflection

func AddSingular Uses

func AddSingular(find, replace string)

AddSingular adds a singular inflection

func AddUncountable Uses

func AddUncountable(values ...string)

AddUncountable adds an uncountable inflection

func GetUncountable Uses

func GetUncountable() []string

GetUncountable retrieves the uncountable inflection values

func Plural Uses

func Plural(str string) string

Plural converts a word to its plural form

func SetIrregular Uses

func SetIrregular(inflections IrregularSlice)

SetIrregular sets the irregular inflections slice

func SetPlural Uses

func SetPlural(inflections RegularSlice)

SetPlural sets the plural inflections slice

func SetSingular Uses

func SetSingular(inflections RegularSlice)

SetSingular sets the singular inflections slice

func SetUncountable Uses

func SetUncountable(inflections []string)

SetUncountable sets the uncountable inflections slice

func Singular Uses

func Singular(str string) string

Singular converts a word to its singular form

type Irregular Uses

type Irregular struct {
    // contains filtered or unexported fields
}

Irregular is a hard replace inflection, containing both singular and plural forms

type IrregularSlice Uses

type IrregularSlice []Irregular

IrregularSlice is a slice of Irregular inflections

func GetIrregular Uses

func GetIrregular() IrregularSlice

GetIrregular retrieves the irregular inflection values

type Regular Uses

type Regular struct {
    // contains filtered or unexported fields
}

Regular is a regexp find replace inflection

type RegularSlice Uses

type RegularSlice []Regular

RegularSlice is a slice of Regular inflections

func GetPlural Uses

func GetPlural() RegularSlice

GetPlural retrieves the plural inflection values

func GetSingular Uses

func GetSingular() RegularSlice

GetSingular retrieves the singular inflection values

Package inflection imports 2 packages (graph). Updated 2017-08-12. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).