diff options
author | Corey Hulen <corey@hulen.com> | 2016-01-19 13:33:57 -0600 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-01-19 13:33:57 -0600 |
commit | 36c5c46e24f745ee80b49f47363217fcb740ce53 (patch) | |
tree | d66189c2ba3c76b76488a3d0dd6ae210ddfc0096 /Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go | |
parent | 80bfdf71f2ab7271dd199c61229fa2b8a7e0213c (diff) | |
parent | 4389571dedb9a68d801427c37ad971c8c488991f (diff) | |
download | chat-36c5c46e24f745ee80b49f47363217fcb740ce53.tar.gz chat-36c5c46e24f745ee80b49f47363217fcb740ce53.tar.bz2 chat-36c5c46e24f745ee80b49f47363217fcb740ce53.zip |
Merge pull request #1921 from mattermost/PLT-7-server-libs
PLT-7 adding server side libraries
Diffstat (limited to 'Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go new file mode 100644 index 000000000..1f3ea5c69 --- /dev/null +++ b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go @@ -0,0 +1,40 @@ +package language + +import ( + "fmt" +) + +// Plural represents a language pluralization form as defined here: +// http://cldr.unicode.org/index/cldr-spec/plural-rules +type Plural string + +// All defined plural categories. +const ( + Invalid Plural = "invalid" + Zero = "zero" + One = "one" + Two = "two" + Few = "few" + Many = "many" + Other = "other" +) + +// NewPlural returns src as a Plural +// or Invalid and a non-nil error if src is not a valid Plural. +func NewPlural(src string) (Plural, error) { + switch src { + case "zero": + return Zero, nil + case "one": + return One, nil + case "two": + return Two, nil + case "few": + return Few, nil + case "many": + return Many, nil + case "other": + return Other, nil + } + return Invalid, fmt.Errorf("invalid plural category %s", src) +} |