问题
I am creating a bot application using Microsoft Bot Framework
and want to localize the bot with multiple languages. I have created resource files but I don't know how to proceed with setting the culture. I know about Localizing MVC Web Application
but I am not getting how do I do this for the Dialogs
in Bot Application
.
回答1:
Create a Resources.resx file for your default language. From there you can create another resx for other languages such as Resources.fr.resx for french. Then change the language in your c# app using something like this:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fr-FR");
Console.WriteLine(Properties.Resources.Hello);
To switch back to default set the culture to anything you haven't accounted for. So if you set culture to "en-EN" it will not find anything because we only have Resources.resx and Resources.fr.resx, so it will return to default (Resources.resx) which could be english, german, or anything else.
来源:https://stackoverflow.com/questions/42856006/how-to-localize-microsoft-bot-application