Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultTemplateName = "translate"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intl ¶
type Intl struct {
// contains filtered or unexported fields
}
func (*Intl) GetMessage ¶
func (i *Intl) GetMessage(key, lang string) (*Translation, error)
GetMessage gets message from db by key+lang
func (*Intl) SetTblNames ¶
func (*Intl) Translate ¶
Translate translates message by key and language, replacing with params from custom struct there should be templated message in db (for particular language) to perform such transformation ex.: Hello {{.Name}}, it's {{.Time}}. Basket: {{.Product}} price is {{.Price}}.
func (*Intl) TranslatePlurals ¶
TranslatePlurals translates any message with plurals based on LocalizeConfig object see: github.com/nicksnyder/go-i18n/v2/i18n it tries to find translation language and makes fallback if not found
ex. of LocalizeConfig:
localizer.Localize(&i18n.LocalizeConfig{ DefaultMessage: &i18n.Message{ ID: "PersonCats", One: "{{.Name}} has {{.Count}} cat.", Other: "{{.Name}} has {{.Count}} cats.", }, TemplateData: map[string]interface{}{ "Name": "Nick", "Count": 2, }, PluralCount: 2, }) // Nick has 2 cats.
type Translation ¶
Click to show internal directories.
Click to hide internal directories.