I have built a bot which can handle two languages(English and German). When user talks to the bot for the first time, it asks the user about language preference and stores it (Rest of the conversation happens in selected language). I am storing that preference in Bot State but it is giving me some concurrency issues. For example if other user changes the language, it gets changed for everyone. How can I avoid this? I am doing following in the root dialog:
context.UserData.SetValue<string>("Language", "de-DE");
Globals.Locale = "de-DE";
And following is Globals class:
public class Globals
{
private static string _locale;
public static string Locale
{
get
{
return _locale;
}
set
{
_locale = value;
}
}
}
And following is how i am setting Culture
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(Globals.Locale);
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(Globals.Locale);
The reason I am using global variable is that i set the culture outside the dialog and i don't have context there. Is there any better way to do it. Thanks