Run my C# application in different language

老子叫甜甜 提交于 2019-12-04 18:47:57
Marcus

You have to get the current culture from the OS and use it as such:

Basically what you need to do is set your current culture of your application somewhere:

Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;

Related: How to set Silverlight CurrentUICulture/CurrentCulture correctly?

If it's a WPF app, I recommend WPFLocalizeExtension. I use it all the time, works perfect.

Thought I would add this here: http://www.west-wind.com/weblog/posts/2009/Jun/14/WPF-Bindings-and-CurrentCulture-Formatting

Basically you add this line of code to your App.xaml:

FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

It then overrides the default language property for every control in your application.

Thanks, Alex.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!