Documentation
¶
Overview ¶
Package msg holds the text Zelie shows people, in a form the web interface can translate. Each message is defined once, with a code and its English text. The web interface's English strings for these codes are generated from the definitions (see TestLocale), and other languages translate the codes. The English text also goes along with every message, for logs and for a language that lacks a code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Other = Define(0, "other.detail", "{detail}")
Other carries text Zelie did not write, such as a tool's error output. It is shown as it is, in every language.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error is a message given as an error, with the HTTP status that goes with it.
func (*Error) WithStatus ¶
WithStatus sends the error with another HTTP status, for a message that fits more than one case.
type Msg ¶
type Msg struct {
Code string `json:"code"`
Params map[string]any `json:"params,omitempty"`
Text string `json:"text"`
}
Msg is one message: its code, the values of its placeholders and its English text.
type Template ¶
type Template struct {
Code string
English string
// Status is the HTTP status an error with this message is sent with,
// or 0 for a message that is only shown, never sent as an error.
Status int
}
Template is a message as defined: {name} marks a value filled in later.
func Define ¶
Define declares a message. It is called from package variables, so a code defined twice or a malformed one stops the program at start.