BotFramework - How to transfer language from DirectLine API

I encode the bot in two languages ​​(en, es), which will always be accessed through the DirectLine API.

the documentation says that:

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

How can I pass a language to BOT from the DirectLine API, so that CurrentCulture can be obtained?

+4
source share
1 answer

I have not found a suitable way to do this, but I am using a workaround.

When you give your user an identifier, add a culture. Like this:

id: 'en-'+ idGeneratedByYou

Then from the controller:

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

Finally, make a switch and depending on it: 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 this will work for you.

0

Source: https://habr.com/ru/post/1653247/


All Articles