Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyListOfVariants = errors.New("Empty list of variants")
ErrEmptyListOfVariants is returned by Format function in strict mode when choice block has no variants ("{X:}")
var ErrEmptyPlaceholderName = errors.New("Empty placeholder name")
ErrEmptyPlaceholderName is returned by Format function in strict mode when placeholder name is empty in the template string ("{}")
var ErrUnmatchedClosingBrace = errors.New("Unmatched } found")
ErrUnmatchedClosingBrace is returned by Format function when there's an unmateched closing curly brace in the template string
var ErrUnmatchedOpeningBrace = errors.New("Unmatched { found")
ErrUnmatchedOpeningBrace is returned by Format function when there's an unmateched opening curly brace in the template string
Functions ¶
func SplitString ¶
SplitString splits the `s` string by `start` and `end` delimiter runes and returns an array of strings including the delimiters
Types ¶
type CallbackFunc ¶
CallbackFunc defines a type of callback function that is called to dynamically get the value of placeholder
type Params ¶
type Params map[string]interface{}
Params type is used to pass placeholder values to Format function
type PlaceholderValueNotDefinedError ¶
type PlaceholderValueNotDefinedError struct {
// contains filtered or unexported fields
}
ErrPlaceholderValueNotDefined is returned by Format function when neither palaceholder not its prefix variant (sans '_PLURAL') is not defined
func (*PlaceholderValueNotDefinedError) Error ¶
func (e *PlaceholderValueNotDefinedError) Error() string
type Plurr ¶
type Plurr struct {
// contains filtered or unexported fields
}
Plurr object
func (*Plurr) Format ¶
Format renders the string based on the template and a list (map) of parameters
func (*Plurr) SetAutoPlurals ¶
SetAutoPlurals sets the 'auto-plurals' mode where the value of 'X_PLURAL' placeholder is calculated automatically by taking the value of 'X' placeholder and passing it through `pluralFunc()`. This mode is enabled by default. Function returns the Plurr object so that calls can be chained.
func (*Plurr) SetCallback ¶
func (p *Plurr) SetCallback(value CallbackFunc) *Plurr
SetCallback sets the callback function to be called by 'plurr.Format' to get placeholder values dynamically. Function returns the Plurr object so that calls can be chained.
func (*Plurr) SetLocale ¶
SetLocale chooses the plural function based on locale name. Function returns the Plurr object so that calls can be chained.
func (*Plurr) SetStrict ¶
SetStrict sets the 'strict' mode where missing placeholder values, as well as non-uint values of placeholders about to be passed through a plural function, are reported as errors. This mode is enabled by default. Function returns the Plurr object so that calls can be chained.
type ValueNotAnIntegerError ¶
type ValueNotAnIntegerError struct {
// contains filtered or unexported fields
}
ErrValueNotAnInteger is returned by Format function in strict mode when placeholder value can't be evaluated to 0 or positive integer
func (*ValueNotAnIntegerError) Error ¶
func (e *ValueNotAnIntegerError) Error() string
type ValueNotDefinedError ¶
type ValueNotDefinedError struct {
// contains filtered or unexported fields
}
ErrValueNotDefined is returned by Format function in strict mode when placeholder value is not provided in the parameters map
func (*ValueNotDefinedError) Error ¶
func (e *ValueNotDefinedError) Error() string