vegapokerbot/internal/locale/localizer.go
Neur0toxine 68f2975201
All checks were successful
continuous-integration/drone/push Build is passing
refactor fsm to pkg, copy more wizard logic to states
2024-05-13 19:08:46 +03:00

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
}