WindowsFormApplication 用户界面支持多语言吗? [英] Multiple languages support for WindowsFormApplication UserInterface?
问题描述
我已经实现了一个 windows 窗体应用程序,在这个应用程序中包含更多用户对应用程序的输入.所以目前在设计中我使用英语作为默认语言..所以现在我想为用户提供多语言支持选项..so 我们如何在 windows 窗体应用程序中实现它?
I have implemented one windows form application,In this application contains more user inputs to the application.So Currently in design i am using English as default language..So now i want to give a multi-language support options to the User..so In how can we implement this in windows Form Application?
推荐答案
您可以尝试使用标准的 microsoft 功能,称为 卫星集会.只需设置表单 Localizible = true
并通过设置 Language = FR
将其翻译成不同的语言(以法语为例).IDE 将创建多个资源,您将在 exe 文件附近看到每种语言作为一个文件夹.切换语言 - 切换当前文化,然后加载/重新加载表单(通过调用它的构造函数):
You can try to use standard microsoft feature, called satellite assemblies. Simply set form Localizible = true
and translate it into different languages by setting Language = FR
(to example into French). IDE will create multiple resources and you will see each language as a folder near exe-file. To switch language - switch current culture and then load/reload form (by calling it's constructor):
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
Form1 form = new Form1();
form.ShowDialog();
另一种方法是使用现成的东西(抱歉,不要使用它们).
Another way is to use something ready made (sorry, don't use them).
最后一种可能性是实现自己的本地化.例如,通过使用反射和自定义转换表.通过这种方式,可以即时切换语言、将翻译构建到软件中或创建自己的工具来维护翻译.过去,我有一些工具可以从资源中生成文本文件然后返回,以便能够将文件发送给某人进行翻译.
And last possibility is to implement own localization. To example, by using reflection and custom translation tables. This way it is possible to switch languages on a fly, build translation into the software or create own tools to maintain translation. In past, I had tools to generate a text file from resources and then back, to be able to send file for translation to someone.
分步指南:
- 创建新的 winform 应用程序,
- 在
form1
中添加label1
, - set
form1.Localizable=true
, - 选择
form1.Language = fr
并更改label1.Text=FR
, - 右键单击重置
form1.Language
(这样您应该会再次看到label1.Text=label1
), - 启动应用程序,您将看到带有label1"文本的
form1
, 现在转到 Program.cs:
- create new winform application,
- add
label1
to theform1
, - set
form1.Localizable=true
, - select
form1.Language = fr
and changelabel1.Text=FR
, - reset
form1.Language
with right click (so you should see againlabel1.Text=label1
), - start application, you will see
form1
with "label1" text on it, now go to Program.cs:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// add this line
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr");
Application.Run(new Form1());
再次启动应用程序,您将看到带有FR"文本的form
.
这篇关于WindowsFormApplication 用户界面支持多语言吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!