package plural
import "zgo.at/z18n/plural"
Package plural provides support for pluralizing messages according to CLDR rules http://cldr.unicode.org/index/cldr-spec/plural-rules
Index ¶
- type Form
- type Operands
- func NewOperands(number interface{}) (*Operands, error)
- func (o *Operands) NEqualsAny(any ...int64) bool
- func (o *Operands) NInRange(from, to int64) bool
- func (o *Operands) NModEqualsAny(mod int64, any ...int64) bool
- func (o *Operands) NModInRange(mod, from, to int64) bool
- type Rule
- type Rules
Types ¶
type Form ¶
type Form string
Form represents a language pluralization form as defined here: http://cldr.unicode.org/index/cldr-spec/plural-rules
const ( Invalid Form = "" Zero Form = "zero" One Form = "one" Two Form = "two" Few Form = "few" Many Form = "many" Other Form = "other" )
All defined plural forms.
type Operands ¶
type Operands struct { N float64 // absolute value of the source number (integer and decimals) I int64 // integer digits of n V int64 // number of visible fraction digits in n, with trailing zeros W int64 // number of visible fraction digits in n, without trailing zeros F int64 // visible fractional digits in n, with trailing zeros T int64 // visible fractional digits in n, without trailing zeros }
Operands is a representation of http://unicode.org/reports/tr35/tr35-numbers.html#Operands
func NewOperands ¶
NewOperands returns the operands for number.
func (*Operands) NEqualsAny ¶
NEqualsAny returns true if o represents an integer equal to any of the arguments.
func (*Operands) NInRange ¶
NInRange returns true if o represents an integer in the closed interval [from, to].
func (*Operands) NModEqualsAny ¶
NModEqualsAny returns true if o represents an integer equal to any of the arguments modulo mod.
func (*Operands) NModInRange ¶
NModInRange returns true if o represents an integer in the closed interval [from, to] modulo mod.
type Rule ¶
Rule defines the CLDR plural rules for a language. http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html http://unicode.org/reports/tr35/tr35-numbers.html#Operands
type Rules ¶
Rules is a set of plural rules by language tag.
func DefaultRules ¶
func DefaultRules() Rules
DefaultRules returns a map of Rules generated from CLDR language data.
func (Rules) Rule ¶
Rule returns the closest matching plural rule for the language tag or nil if no rule could be found.
Source Files ¶
doc.go form.go operands.go rule.go rule_gen.go rules.go
Directories ¶
Path | Synopsis |
---|---|
plural/codegen |
- Version
- v0.0.0-20240522230155-4d5af439f8c4 (latest)
- Published
- May 22, 2024
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 3 weeks ago –
Tools for package owners.