Neur0toxine
68f2975201
All checks were successful
continuous-integration/drone/push Build is passing
33 lines
580 B
Go
33 lines
580 B
Go
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
|
|
}
|