Documentation ¶
Index ¶
- Variables
- func Get(module string, key string) string
- func GetIn(lang string, module string, key string) string
- func Replace(str string, m map[string]string) string
- type Collection
- type Component
- type ComponentLabels
- type Label
- type Labels
- type LabelsComponent
- type Language
- type MapLabels
- type Message
- type Messages
- type StringLabel
- type TemplateMessage
- type Translatable
- type Translated
- type TranslationLanguage
- type Translations
- func (c *Translations) Get(lang string, module string, key string) string
- func (c *Translations) GetMessages(lang string, module string) *Messages
- func (c *Translations) Load(lang string, module string, key string) (string, bool)
- func (c *Translations) SetMessages(lang string, module string, m *Messages)
Constants ¶
This section is empty.
Variables ¶
var DefaultTranslations = NewTranslations()
DefaultTranslations default messages Translations
var Lang = ""
Lang default langauge used by Translate func.
Functions ¶
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection struct which hold avaliable message map and translated messages.
func NewCollection ¶
func NewCollection(messages *Messages, messagesmap map[string]string) *Collection
NewCollection create new map with given avaliable map and translated messages.
func (*Collection) GetLabel ¶
func (m *Collection) GetLabel(field string) string
GetLabel get translated field label .
type ComponentLabels ¶
type ComponentLabels interface { GetComponentLabels() Labels SetComponentLabels(Labels) GetLabel(string) string }
ComponentLabels ui component with labels
type LabelsComponent ¶
type LabelsComponent struct {
// contains filtered or unexported fields
}
LabelsComponent component struct with labels
func (*LabelsComponent) ComponentID ¶
func (c *LabelsComponent) ComponentID() string
ComponentID return component id
func (*LabelsComponent) GetComponentLabels ¶
func (c *LabelsComponent) GetComponentLabels() Labels
GetComponentLabels get labels from component
func (*LabelsComponent) GetLabel ¶
func (c *LabelsComponent) GetLabel(field string) string
GetLabel get label from componet labels
func (*LabelsComponent) SetComponentLabels ¶
func (c *LabelsComponent) SetComponentLabels(labels Labels)
SetComponentLabels get labels from component
type Language ¶
type Language struct {
// contains filtered or unexported fields
}
Language translation language struct
type Message ¶
Message message which should be translated
func NewMessage ¶
NewMessage create new message with given module and text.
func (*Message) Translate ¶
Translate translate message with default translations. if lang if empty,Lang will be used.
func (*Message) TranslateWith ¶
func (m *Message) TranslateWith(t *Translations, lang string) string
TranslateWith translate message with given translations and language
func (*Message) Translated ¶
func (m *Message) Translated(lang string) *Translated
Translated create translated message by given language
type Messages ¶
Messages translate messages map.
func GetMessages ¶
GetMessages by given lang and modules Default Lang will used if lang is empty
func (*Messages) Collection ¶
func (m *Messages) Collection(messagesmap map[string]string) *Collection
Collection create collection with given messagesmap
func (*Messages) Get ¶
Get get translated string for key. Return key if translateed string not exist.
type TemplateMessage ¶
type TemplateMessage struct {
// contains filtered or unexported fields
}
TemplateMessage message with template
func NewTemplateMessage ¶
func NewTemplateMessage(module string, message string, tokens map[string]string) *TemplateMessage
NewTemplateMessage create new message with given module and text.
func (*TemplateMessage) Translate ¶
func (m *TemplateMessage) Translate(lang string) string
Translate translate message with default translations. if lang if empty,Lang will be used.
func (*TemplateMessage) TranslateWith ¶
func (m *TemplateMessage) TranslateWith(t *Translations, lang string) string
TranslateWith translate message with given translations and language
func (*TemplateMessage) Translated ¶
func (m *TemplateMessage) Translated(lang string) *Translated
Translated create translated message by given language
type Translatable ¶
Translatable interface which can be translated
type Translated ¶
type Translated struct {
// contains filtered or unexported fields
}
Translated translated message
func NewTranslated ¶
func NewTranslated(translateable Translatable, lang string) *Translated
NewTranslated create new translated message
type TranslationLanguage ¶
TranslationLanguage translateable interface
type Translations ¶
Translations messages collection grouped by lang and module.
func NewTranslations ¶
func NewTranslations() *Translations
NewTranslations create new messages Translations
func (*Translations) Get ¶
func (c *Translations) Get(lang string, module string, key string) string
Get load get message by given lang,module and key. Return translated message if found. Return raw message if not found
func (*Translations) GetMessages ¶
func (c *Translations) GetMessages(lang string, module string) *Messages
GetMessages get messages by given lang and module Return nil if messages not found
func (*Translations) Load ¶
Load load translated message by given lang.module and key. Return translated message and true if found. Return raw message and false if not found
func (*Translations) SetMessages ¶
func (c *Translations) SetMessages(lang string, module string, m *Messages)
SetMessages set collection messages by given lang and module