From 4389571dedb9a68d801427c37ad971c8c488991f Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 19 Jan 2016 10:54:19 -0600 Subject: PLT-7 adding server side libraries --- .../nicksnyder/go-i18n/i18n/language/plural.go | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go (limited to 'Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go') 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) +} -- cgit v1.2.3-1-g7c22