日期:2014-05-17  浏览次数:20843 次

请教中英转换问题
用资源文件可以对控件的一些显示进行中英转换,但是程序里面一些string呢?怎么办?

------解决方案--------------------
也用资源文件啊。
如果当前线程的语言不是需要输出的语言的话,先设置一下culture
C# code

Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-CN");

------解决方案--------------------
不要把字符串硬编码到程序里面。

比如

MessageBox.Show("Hello");

你应该这么写:
MessageBox.Show(LanguageService.GetString(ID_SAYHELLO));

假设你把资源放在LanguageService.dll里面。