4
votes

I'm coding a bot in two languages (en, es) which will always be accessed via DirectLine API.

The documentation says that:

The localization language is determined by the current thread's CurrentUICulture and CurrentCulture.

What is the proper way to pass the language to the BOT from the DirectLine API, so can be getted by CurrentCulture?

1

1 Answers

0
votes

I haven't found out a proper way to do it, but I use a workaround.

When you give your user an ID, add the culture. Like this:

id: 'en-'+ idGeneratedByYou

Then from the controller:

var culture = activity.From.Id.Split('-')[0];

Finally, do a switch and depending it is en or es:

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-ES");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-ES");

I know this is not the best way, but maybe it will work out for you.