I have such code but locale does not updated after choosing. For example I choose French but default locale are used. Could you help to resolve this problem ?
i18n.configure({
directory: __dirname + '/locales',
defaultLocale: 'en',
register: bot,
});
const listenConditions = new Map();
function setLocale(ctx, locale) {
i18n.setLocale(ctx, locale);
}
bot.start((ctx) => {
setLocale(ctx, "en");
ctx.reply(i18n.__("language_selection"), Markup.keyboard([
[i18n.__("language_english"), i18n.__("language_russian")],
[i18n.__("language_ukrainian"), i18n.__("language_french")]
]));
});
bot.hears(i18n.__("language_english"), (ctx) => {
setLocale(ctx, "en");
ctx.reply(i18n.__("language_selected", { language: "English" }));
showServiceOptions(ctx);
});
bot.hears(i18n.__("language_russian"), (ctx) => {
setLocale(ctx, "ru");
ctx.reply(i18n.__("language_selected", { language: "Русский" }));
showServiceOptions(ctx);
});
bot.hears(i18n.__("language_ukrainian"), (ctx) => {
setLocale(ctx, "uk");
ctx.reply(i18n.__("language_selected", { language: "Українська" }));
showServiceOptions(ctx);
});
bot.hears(i18n.__("language_french"), (ctx) => {
setLocale(ctx, "fr");
ctx.reply(i18n.__("language_selected", { language: "Français" }));
showServiceOptions(ctx);
});
I tried to debug but I don't understand what's wrong