conversations icon indicating copy to clipboard operation
conversations copied to clipboard

Troubles with changing locale inside of conversation

Open archimag opened this issue 2 years ago • 3 comments

Hi!

I use redis session storage, i18n and convesation plugins. Now I am working on Settings dialogue. I want to ask from user the new locale, to change current one and to reply with using of new locale. But inside of conversation the object ctx.i18n just don't real (becasue it restored from session data) and so I cannot to call of ctx.i18n.setLocale.

How I can solve this problem? Thank you.

P.S. Regadless of this issue I want to say - very nice and useful library.

archimag avatar Apr 06 '23 10:04 archimag

I have solved the problem but it is a hack:

ctx = (conversation as any).ctx;
ctx.session.locale = locale;
await ctx.i18n.renegotiateLocale();

archimag avatar Apr 06 '23 13:04 archimag

This needs to be investigated and fixed

KnorpelSenf avatar May 20 '23 23:05 KnorpelSenf

Before I try to investigate this, can you check if using conversation.session fixes the issue? https://grammy.dev/plugins/conversations.html#rule-iii-use-convenience-functions

/cc @dcdunkan perhaps you may an idea what causes this

KnorpelSenf avatar Jun 14 '23 09:06 KnorpelSenf