Documentation ¶
Index ¶
Constants ¶
const (
MsgLocaleSetAppLangugeInterface = "LocaleSetAppLangugeInterface"
)
Variables ¶
var T = func(messageID string, template interface{}) string { if GlobalLocalizer == nil { SetLanguage("") } return GlobalLocalizer.Translate(messageID, template) }
One of 2 main methods to translate message ID text, using format functionality based on template interface.
var TP = func(messageID string, template interface{}, pluralCount interface{}) string { if GlobalLocalizer == nil { SetLanguage("") } return GlobalLocalizer.TranslatePlural(messageID, template, pluralCount) }
One of 2 main methods to translate message ID text, using format functionality based on template interface. Extra functionality allow to control plural form behavior.
Functions ¶
func SetLanguage ¶
func SetLanguage(lang string)
SetLanguage set up language globally for application localization.
Types ¶
type Localizer ¶
Localizer is a stub to get access to *i18n.Localizer. As it found, *i18n.Localizer is not a thread safe, so sync.Mutex must be used to synchronize calls to object internals.
var GlobalLocalizer *Localizer
GlobalLocalizer is a global variable to translate everything in application
func CreateLocalizer ¶ added in v0.3.3
CreateLocalizer create localizer object to generate text messages.
func (*Localizer) Translate ¶ added in v0.3.3
Translate form and output a message based on messageID and template configuration.
func (*Localizer) TranslatePlural ¶ added in v0.3.3
func (v *Localizer) TranslatePlural(messageID string, template interface{}, pluralCount interface{}) string
TranslatePlural form and output a message based on messageID, template and pluralCount configuration.