-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: telebot/layout #541
Labels
Comments
Anyway, figured it out myself.
greeting: Hello
good_bye: Bye
import (
tele "gopkg.in/telebot.v3"
"gopkg.in/telebot.v3/layout"
)
var tgbot *tele.Bot
var lt *layout.Layout
func InitBot(settings tele.Settings) {
var err error
tgbot, err = tele.NewBot(settings)
if err != nil {
panic(err)
}
lt, err = layout.New("layout.yml")
if err != nil {
panic(err)
}
// Middlewares first argument is 'fallback' locale
tgbot.Use(lt.Middleware("en", getUserLocale))
}
func getUserLocale(r tele.Recipient) string {
// your get locale logic
return "en"
}
func handler(c tele.Context) error {
tgbot.Send(c.Sender(), lt.Text(c, "greeting"))
return err
} You can find other methods in layout/layout.go |
demget
changed the title
Any documentation about how to use layout package?
Documentation for the layout package
Oct 1, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. First of all, thanks for amazing library :)
I'm wondering if there are some how-tos about layout package? As far as I understand this package helps to handle multiple locales
I'm building multilangual bot that replies depending on language that user sets at the start/settings.
The text was updated successfully, but these errors were encountered: