2024-05-09 17:42:42 +03:00
|
|
|
package iface
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/locale"
|
2024-05-09 23:26:21 +03:00
|
|
|
"strings"
|
2024-05-09 17:42:42 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type Base struct {
|
2024-05-09 20:48:59 +03:00
|
|
|
App App
|
2024-05-09 17:42:42 +03:00
|
|
|
UserID int64
|
|
|
|
ChatID int64
|
|
|
|
}
|
|
|
|
|
2024-05-09 20:48:59 +03:00
|
|
|
func NewBase(app App, userID int64, chatID int64) Base {
|
2024-05-09 17:42:42 +03:00
|
|
|
return Base{app, userID, chatID}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b Base) Localizer(lang string) locale.Localizer {
|
2024-05-09 23:26:21 +03:00
|
|
|
lang = strings.ToLower(lang)
|
2024-05-09 17:42:42 +03:00
|
|
|
if len(lang) > 2 {
|
|
|
|
lang = lang[:2]
|
|
|
|
}
|
|
|
|
switch lang {
|
|
|
|
case "en", "ru":
|
|
|
|
return b.App.Localizer(lang)
|
|
|
|
default:
|
|
|
|
return b.App.Localizer("en")
|
|
|
|
}
|
|
|
|
}
|