Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context = string
Context is an alias type for string which is used by xspreak for extracting strings.
type Domain ¶
type Domain = string
Domain is an alias type for string which is used by xspreak for extracting strings.
type Error ¶
Error is returned when a Localizer or Locale translates an error into the target language.
type Key ¶ added in v0.3.0
type Key = string
Key is an alias type for string which is used by xspreak for extracting strings. The exported key is not stored as text, only the key is stored. Should only be used when messages are identified by keys and not by strings. For example when using JSON.
type Localizable ¶
type Localizable interface { // GetMsgID specifies the message id (singular) for which the message should be translated. GetMsgID() string // GetPluralID specifies the plural for which the message should be translated. GetPluralID() string // GetContext specifies the context for which the message should be translated. GetContext() string // GetVars is optional, can be used to pass parameters. GetVars() []interface{} GetCount() int // HasDomain specifies whether the domain of Domain() is to be used. // If false the default domain is used. HasDomain() bool // GetDomain specifies the domain for which the message should be translated. GetDomain() string }
A Localizable allows access to a message that needs to be translated.
An implementation can be passed directly to a spreak.Localizer or spreak.Locale via l.Localize(impl) to obtain a translation.
type Message ¶
type Message struct { Singular Singular Plural Plural Context Context Vars []interface{} Count int }
Message is a simple struct representing a message without a domain. Can be converted to a translated string by spreak.Localizer or spreak.Locale.
func (*Message) GetContext ¶
func (*Message) GetPluralID ¶
type MsgID ¶
type MsgID = string
MsgID is an alias type for string which is used by xspreak for extracting strings MsgID and Singular are synonymous and both represent the ID to identify the message.
type Plural ¶
type Plural = string
Plural is an alias type for string which is used by xspreak for extracting strings.
type PluralKey ¶ added in v0.3.0
type PluralKey = string
PluralKey is an alias type for string which is used by xspreak for extracting strings. It represents a MsgId AND a PluralId which identify a message. The exported key is not stored as text, only the key is stored. Should only be used when messages are identified by keys and not by strings. For example when using JSON.