我正在构建一个企业 C#.net 应用程序,要求有阿拉伯语和英语版本.客户提供了 2 个选项,要么将英语和阿拉伯语一起写成标签和描述,要么放置一个组合框,开始选择英语和阿拉伯语并继续使用该语言.我想节省我的时间,并希望我可以构建一个英文版本,并且必须自动翻译阿拉伯语.
I am building an enterprise C#.net application, the requirement is there will be Arabic and English version both. 2 options are given from client, either to write English plus Arabic together for labels and descriptions or to place a combo box in start having English and Arabic to select and to proceed with that language. I want to save my time and want that i could just build an English version and Arabic must be auto translated.
提前致谢.
首先,你不需要选择任何东西,如果有人在他/她的操作系统中设置了阿拉伯语区域设置,它就已经被选中了.要检测使用的语言(如果您需要此信息,通常不需要),您只需阅读 System.Globalization.CultureInfo.CurrentUICulture
属性.
First of all, you do not need to select anything, it would be already selected if somebody set Arabic Locale in his/her Operating System. To detect what language is used (if you need this information, usually you don't) you would simply read System.Globalization.CultureInfo.CurrentUICulture
property.
但是,在 WinForms 中,您实际上可以使用内置的本地化支持.为此,您需要将 Form Localizable
属性切换为 true.假设您提供了阿拉伯语字符串,您需要将 Form 的 Language
属性从(默认)切换到阿拉伯语 完成英语布局并将翻译放置在适当的位置.这是最简单的方法.在使用阿拉伯语时,您还需要将 Form 的 RightToLeft
属性切换为 Yes 并将 RightToLeftLayout
切换为 True.
如果您正确执行此操作,您会看到该表单已镜像.这是理想的情况,不要惊慌.
However, in WinForms you could actually use built-in Localization support. To do that, you need to switch Form Localizable
property to true. Assuming that you have Arabic strings provided, you would need to switch Form's Language
property from (default) to Arabic after you complete you English layout and place the translations in appropriate places. That is the easiest way. You would also need to switch Form's RightToLeft
property to Yes and RightToLeftLayout
to True while on Arabic.
If you do that properly, you would see that form is mirrored. That's desired situation, do not panic.
更糟糕的是,您有时需要显示消息框.这里的问题是,根据您使用的语言类型,您实际上需要以不同的方式进行操作,因为阿拉伯语(和其他 RTL 语言)需要使用 RTLReading 常量:
The worse part is that you would occasionally need to display Message Boxes. The problem here is, that depending on what language type you are using, you actually would need to do it in a different way, for Arabic (and other RTL languages) require that RTLReading constant be used:
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
{
MessageBox.Show(text, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
}
else
{
MessageBox.Show(text, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
这就是高级别的......
That's it on the high level...
这篇关于英文桌面 C#.net 应用程序中的阿拉伯语本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!