Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message interface { // GetID returns the unique identity of the message. GetID() string // GetHash returns the unique identity of the message content. GetHash() string // GetDescription returns the description of the message. GetDescription() string // GetLeftDelim returns the left Go template delimiter. GetLeftDelim() string // GetRightDelim returns the right Go template delimiter. GetRightDelim() string // GetZero returns the content of the message for the CLDR plural form "zero". GetZero() string // GetOne returns the content of the message for the CLDR plural form "one". GetOne() string // GetTwo returns the content of the message for the CLDR plural form "two". GetTwo() string // GetFew returns the content of the message for the CLDR plural form "few". GetFew() string // GetMany returns the content of the message for the CLDR plural form "many". GetMany() string // GetOther returns the content of the message for the CLDR plural form "other". GetOther() string }
Message is the interface of message which can be localized.
type MessagePack ¶
MessagePack is the interface of message pack which can be localized.
type Parser ¶
type Parser interface {
Parse([]byte) (MessagePack, error)
}
type Translator ¶
type Translator interface { // T translates a message. T(id string, data ...any) string // P translates a message with a plural count. P(id string, pluralCount any, data ...any) string // M translates a [Message] M(msg Message) string // Locale creates a translator for the given languages. Locale(languages ...string) Translator // AddMessages adds messages to the bundle. AddMessages(language string, messages ...Message) error // AddMessagesByLanguageTag adds messages to the bundle by language tag. AddMessagesByLanguageTag(language language.Tag, messages ...Message) error // LoadMessage loads messages from a loader and parser. LoadMessage(loader Loader, parser Parser) error // LoadMessageFile loads messages from a file. LoadMessageFile(path string) error // LoadMessageFileFS loads messages from a file from the given file system. LoadMessageFileFS(fsys fs.FS, path string) error // LoadMessageRemote loads messages from a remote url. LoadMessageRemote(remote string, parser Parser) error // LoadMessageRemoteRequest loads messages from a custom request LoadMessageRemoteRequest(req *http.Request, parser Parser, clientOpts ...func(client *http.Client) error) error // RegisterUnmarshalFunc registers a custom unmarshal function for the given format RegisterUnmarshalFunc(format string, unmarshaller func(data []byte, v any) error) // LanguageTags returns the supported language tags. LanguageTags() []language.Tag }
Translator is the interface for creating localizers.
Click to show internal directories.
Click to hide internal directories.