type Catalog … // NewFromMap creates a Catalog from the given map. If a Dictionary is // underspecified the entry is retrieved from a parent language. func NewFromMap(dictionaries map[string]Dictionary, opts ...Option) (Catalog, error) { … } type Dictionary … type catalog … func (c *catalog) Languages() []language.Tag { … } func (c *catalog) Matcher() language.Matcher { … } func (c *catalog) lookup(tag language.Tag, key string) (data string, ok bool) { … } // Context returns a Context for formatting messages. // Only one Message may be formatted per context at any given time. func (c *catalog) Context(tag language.Tag, r catmsg.Renderer) *Context { … } type Builder … type options … type Option … // Fallback specifies the default fallback language. The default is Und. func Fallback(tag language.Tag) Option { … } // NewBuilder returns an empty mutable Catalog. func NewBuilder(opts ...Option) *Builder { … } // SetString is shorthand for Set(tag, key, String(msg)). func (c *Builder) SetString(tag language.Tag, key string, msg string) error { … } // Set sets the translation for the given language and key. // // When evaluation this message, the first Message in the sequence to msgs to // evaluate to a string will be the message returned. func (c *Builder) Set(tag language.Tag, key string, msg ...Message) error { … } // SetMacro defines a Message that may be substituted in another message. // The arguments to a macro Message are passed as arguments in the // placeholder the form "${foo(arg1, arg2)}". func (c *Builder) SetMacro(tag language.Tag, name string, msg ...Message) error { … } var ErrNotFound … // String specifies a plain message string. It can be used as fallback if no // other strings match or as a simple standalone message. // // It is an error to pass more than one String in a message sequence. func String(name string) Message { … } // Var sets a variable that may be substituted in formatting patterns using // named substitution of the form "${name}". The name argument is used as a // fallback if the statements do not produce a match. The statement sequence may // not contain any Var calls. // // The name passed to a Var must be unique within message sequence. func Var(name string, msg ...Message) Message { … } // Context returns a Context for formatting messages. // Only one Message may be formatted per context at any given time. func (b *Builder) Context(tag language.Tag, r catmsg.Renderer) *Context { … } type Context … // Execute looks up and executes the message with the given key. // It returns ErrNotFound if no message could be found in the index. func (c *Context) Execute(key string) error { … }