Go library for plurals of nouns, ordinalize numbers, parameterize/transliterate/camelize/underscore strings, convert numbers to words and more
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
camelize.go
camelize_test.go
circle.yml
consonant_vowel.go
consonant_vowel_test.go
doc.go
into_words.go
into_words_test.go
ordinal.go
ordinal_test.go
parameterize.go
parameterize_test.go
plural.go
plural_test.go
transliterate.go
transliterate_test.go
underscore.go
underscore_test.go

README.md

inflect

Circle CI Build Status Coverage Status GoDoc Go Report Card

Installing

go get

$ go get -u github.com/martinusso/inflect

Using

IntoWords()

IntoWords convert numbers (float64) to words

func IntoWords(number float64) string 
got := IntoWords(42)  // -> forty-two
got := IntoWords(-147)  // -> Minus one hundred and forty-seven

IsConsonant

IsConsonant check if a character is a consonant

func IsConsonant(s string) bool

IsVowel

IsVowel check if a character is a vowel

func IsVowel(s string) bool

Ordinal

Ordinal returns the ordinal suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th...

func Ordinal(number int) string
got := Ordinal(-1)  // -> st
got := Ordinal(42)  // -> nd

Ordinalize

Ordinalize turns a number into an ordinal string

func Ordinalize(number int) string
got := Ordinal(-1)  // -> -1st
got := Ordinal(42)  // -> 42nd

Parameterize

Parameterize replaces special characters in a pretty string

func Parameterize(s string) string
got := Parameterize("J. R. R. Tolkien")  // -> "j-r-r-tolkien"

ParameterizeSep

ParameterizeSep replaces special characters, according to the separator, in a string

func ParameterizeSep(s, sep string) string
got := ParameterizeSep("J. R. R. Tolkien", "_")  // -> "j_r_r_tolkien"

Pluralize

Pluralize generates the plurals of nouns

func Pluralize(word string) string
got := Plural("word") // -> words
got := Plural("noun") // -> nouns

License

This software is open source, licensed under the The MIT License (MIT). See LICENSE for details.