Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( GlobalTrans = &Translator{ localizes: make(map[i18n.Language]*goI18n.Localizer), jsonData: make(map[i18n.Language]any), } Bundle = goI18n.NewBundle(language.English) )
GlobalTrans global translation
Functions ¶
func AddTranslator ¶
AddTranslator add translator to global translations translation is content language is language file name like en_US.yaml
func NewTranslator ¶
func NewTranslator(bundleDir string) (i18n.Translator, error)
NewTranslator new translator from Bundle/resource directory TODO: singleton and multi-thread safe initialization
Types ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator save the language type with localizer mapping
func (*Translator) Dump ¶
func (tr *Translator) Dump(la i18n.Language) ([]byte, error)
Dump the translator into json format
func (*Translator) Tr ¶
func (tr *Translator) Tr(la i18n.Language, key string) string
Tr to Translate from specified language and string TODO: improve multi-threading performance
func (*Translator) TrWithData ¶
TrWithData to Translate from specified language and string
Click to show internal directories.
Click to hide internal directories.