vegapokerbot/internal/locale/localizer.go
Neur0toxine 2cd46585a8
All checks were successful
continuous-integration/drone/push Build is passing
add hot-reload & debugger
2024-05-14 15:26:28 +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
}