Winform .net中的全球化/本地化问题 [英] globalization/localization problem in winform .net

查看:76
本文介绍了Winform .net中的全球化/本地化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在c#中开发了.exe的Windows应用程序(.net中的winform)输出.我希望该exe支持多种语言.在这方面,任何人都可以帮助我吗?

一切都准备好我的exe开发.现在我想用谷歌翻译器和resx文件将英语改为阿拉伯语.

i have developed windows application(winform in .net) output of an .exe in c#. i want that exe to support multiple language. can any one help me in this regard to how to do it?

all ready my exe developed. now i want to change english to arabic with out using google translator and resx file. how can i handle it?

推荐答案

请参考:
CP搜索 [有关CP的更多答案 [全球化/语言转换问题 [全球化概念问题 [
Please refer:
CP Search[^]
and Some more answers on CP[^]

Don''t re-post
You''ve already ask''d this question:
globalization/Language conversion problem[^]
globalization concept problem[^]


首先,您需要执行全球化.首先,这意味着您将所有常量(包括在代码中硬编码的立即常量;理想情况下,根本不应该使用它们)放在* .resx资源中.此外,您所有的表格布局都应自动运行,以在运行时调整为所有字符串的大小.它要求彻底的尺寸公差设计:永远都不要对所有设计元素都使用属性DockPadding进行绝对定位/调整大小,依此类推.您可以通过在资源中植入随机文本来对其进行测试.

当您从左到右切换到从右到左时,更困难的问题是布局的自动更改,因为这是阿拉伯语.请查看控件类并研究所有*RightToLeftRtl*成员:
http://msdn.microsoft.com/en-us/library/system. windows.forms.control.aspx [ ^ ].

这不是那么简单,因为这不仅与文本的方向有关.例如,如果在西方文化中您可以在左侧有标签,在右侧有标签控件,那么在阿拉伯语窗口中应该是相反的(就我所记得的阿拉伯语页面的外观而言,我并没有误会).

当这工作并经过测试时,您可以进入 localization ,如果全球化部分得到了很好的实施和测试,则应该会更容易. .NET提供了一种基于卫星程序集的强大机制.基本上,它看起来像这样:只将资源文件传递给翻译器;将资源文件传递给翻译器.而且他们甚至不需要Visual Studio(因为MSBuild作为.NET Framework的一部分提供,对于构建来说已经足够了);执行翻译编译资源以创建一些名为 satellite组件的仅资源的组件,所有这些组件均与原始资源一一对应.他们不必翻译所有内容,因为有一个后备机制:如果找不到资源,则来自最接近区域性的资源将成为用户,一直到产品的原始资源.

完成此操作后,您只需将新程序集放在以区域性ID命名的子目录中.该框架将在需要时自动查找和加载资源,具体取决于应用程序主(UI)线程的当前UI文化.产品的主要代码无需重新编译.翻译时长不需要完整的源代码.仅向他们提供了一部分资源,当然,还提供了适当功能的完整功能原始产品的副本以及详细的文档.

切换文化可能有不同的方案.最终,它可以在运行时正确切换.一旦发生,资源将自动加载.请查看操作方法:
http://msdn.microsoft.com/en-us/library/system. threading.thread.currentuiculture.aspx [ ^ ].

在其他情况下,可以在应用程序配置文件中指定区域性,也可以通过安装过程进行安装.还有一种机制可以从部署网站查询用于所需区域性的资源,并在有所需区域性的资源可用时自动下载它们.

欲了解更多信息,请参见:
http://msdn.microsoft.com/en-us/library/aa292205%28v = vs.71%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/aa291552%28v = vs.71%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ms753931.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ms788718.aspx [ ^ ],
http://msdn.microsoft.com/en-us/goglobal/bb688142.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/21a15yht%28v = vs.100%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/70s77c20.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/70s77c20.aspx [ ^ ].

—SA
First, you need to perform globalization. First of all, it means that you put all your constants (including immediate constants hard-coded in the code; ideally, you should not have them at all) in *.resx resources. Besides, all your form layout should be automated to be adjusted to sizes of all the strings during run time. It requires thorough size-tolerant design: no absolute positioning/sizing, ever, using of the properties Dock and Padding for all elements of design, and so on. You can test it by seeding random text into the resources.

More difficult problem would be automatic change in layout when you switch from left-to-right to right-to-left, because this is Arabic. Please look at the control class and study all the *RightToLeft and Rtl* members:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx[^].

This is not so simple, because this is not just about the direction of the text. For example, if in Western culture you can have labels on left and labelled controls on right, in Arabic window it should be the opposite (it I''m not much mistaken, as far as I remember how Arabic pages look).

When this works and tested, you can get to localization, which should be easier if globalization part is perfectly implemented and tested. .NET provide a powerful mechanism based on satellite assemblies. Basically, it looks like this: you pass only the resource files to the translators; and they don''t even need Visual Studio (because MSBuild is provided as a part of .NET Framework and quite enough for the build); the perform translation compile resources to create some resource-only assemblies called satellite assemblies, all in one-to-one correspondence with original resources. They don''t have to translate everything, as there is a fallback mechanism: if a resource not found, a resource from the closest culture will be user, all the way down to original resources of your product.

When this is done, you simply put the new assemblies in the sub-directories named after the culture IDs. The framework will automatically find and load resources when they are needed, depending on the current UI culture of the main (UI) thread of the application. The main code of the product never needs to be re-compiled. The translation teem never needs the full source code. They are given only the part with resources and, of course, appropriate number of copies of the fully functional original product with detailed documentation.

There can be different scenarios for switching the cultures. Ultimately, it can be switched right during runtime. As soon as it happens, the resources are loaded automatically. Please see how to do it:
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentuiculture.aspx[^].

In other scenarios, the culture could be prescribed in application configuration file or installed by an installation process. There is also a mechanism for querying resources for required culture from the deployment Web site and automatically downloading them if the resource for a required culture are available.

For further reading, please see:
http://msdn.microsoft.com/en-us/library/aa292205%28v=vs.71%29.aspx[^],
http://msdn.microsoft.com/en-us/library/aa291552%28v=vs.71%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms753931.aspx[^],
http://msdn.microsoft.com/en-us/library/ms788718.aspx[^],
http://msdn.microsoft.com/en-us/goglobal/bb688142.aspx[^],
http://msdn.microsoft.com/en-us/library/21a15yht%28v=vs.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/70s77c20.aspx[^],
http://msdn.microsoft.com/en-us/library/70s77c20.aspx[^].

—SA


这篇关于Winform .net中的全球化/本地化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆