cldrplural

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2022 License: BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Overview

This file is generated by cldrplural/generator/generate.sh; DO NOT EDIT

Index

Constants

This section is empty.

Variables

View Source
var CategoryNames = map[Category]string{
	Zero:  "Zero",
	One:   "One",
	Two:   "Two",
	Few:   "Few",
	Many:  "Many",
	Other: "Other",
}
View Source
var OperandMap = map[string]Operand{
	"n": OperandN,
	"i": OperandI,
	"v": OperandV,
	"w": OperandW,
	"f": OperandF,
	"t": OperandT,
	"c": OperandC,
	"e": OperandC,
}

Functions

This section is empty.

Types

type Category

type Category int
const (
	Zero Category = iota
	One
	Two
	Few
	Many
	Other
)

func (Category) String

func (cat Category) String() string

type FormFunc

type FormFunc func(ops *Operands) Category

type Operand

type Operand int
const (
	OperandN Operand = iota // the absolute value of N.*
	OperandI                // the integer digits of N.*
	OperandV                // the number of visible fraction digits in N, with trailing zeros.*
	OperandW                // the number of visible fraction digits in N, without trailing zeros.*
	OperandF                // the visible fraction digits in N, with trailing zeros, expressed as an integer.*
	OperandT                // the visible fraction digits in N, without trailing zeros, expressed as an integer.*
	OperandC                // compact decimal exponent value: exponent of the power of 10 used in compact decimal formatting.
)

func (Operand) String

func (op Operand) String() string

type Operands

type Operands struct {
	N float64
	I int64
	V int64
	W int64
	F int64
	T int64
	C int64
}

The Operands are numeric values corresponding to features of the source number.

func MustNewOperands

func MustNewOperands(a interface{}) *Operands

func NewOperands

func NewOperands(a interface{}) (*Operands, error)

NewOperands converts the representation of a float value into the appropriate Operands.

type RuleSet

type RuleSet struct {
	Categories []Category
	FormFunc   FormFunc
}

func ForLanguage

func ForLanguage(lang language.Tag) (*RuleSet, bool)

ForLanguage returns the set of rules for a language. If no matching language is found, the English rule set and false are returned.

func MustParseRules

func MustParseRules(rules map[Category]string) *RuleSet

func ParseRules

func ParseRules(rawRules map[Category]string) (*RuleSet, error)

ParseRules creates a RuleSet from a set of rules, which can be evaluated at runtime.

func (*RuleSet) Evaluate

func (rs *RuleSet) Evaluate(a interface{}) Category

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL