package locale import ( "github.com/nicksnyder/go-i18n/v2/i18n" "golang.org/x/text/language" ) type Localizer interface { Message(string) string Template(string, interface{}) string Tag() language.Tag } type localizer struct { loc *i18n.Localizer tag language.Tag } func (l *localizer) Message(str string) string { return l.Template(str, nil) } func (l *localizer) Template(str string, tpl interface{}) string { return l.loc.MustLocalize(&i18n.LocalizeConfig{ MessageID: str, TemplateData: tpl, }) } func (l *localizer) Tag() language.Tag { return l.tag }