Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Translator ¶
type Translator struct { // The default language key. // This key is used if no language is specified or if // the text for the chosen language is an empty string. Default string // contains filtered or unexported fields }
func NewTranslator ¶
func NewTranslator(resources io.Reader) (Translator, error)
func (*Translator) Get ¶
func (t *Translator) Get(key, langKey string) string
Gets the translation for the specified language. If either the language or the key is not found, an empty string is returned. If the resulting text is an empty string, the default language is chosen instead. If the t.Default is "", the fallback mechanism is deactivated.
func (*Translator) GetDefault ¶
func (t *Translator) GetDefault(key string) string
Gets the translation for the default language. If the default is set to empty, an empty string is returned.
func (*Translator) TryGet ¶
func (t *Translator) TryGet(key, langKey string) (string, bool)
Gets the translation for the language. If the language or the key is not found, an empty string and a 'false' value is returned. If the text is an empty string, the default language is chosen instead. If the t.Default is "", the fallback mechanism is deactivated.
Click to show internal directories.
Click to hide internal directories.