英语桌面 C#.net 应用程序中的阿拉伯语本地化

发布于 2024-11-28 18:46:57 字数 158 浏览 1 评论 0原文

我正在构建一个企业 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.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光是把杀猪刀 2024-12-05 18:46:57

首先,您不需要选择任何内容,如果有人在他/她的操作系统中设置了阿拉伯语区域设置,那么它就已经被选择了。要检测使用的语言(如果您需要此信息,通常不需要),您只需读取 System.Globalization.CultureInfo.CurrentUICulture 属性即可。

然而,在 WinForms 中您实际上可以使用内置的本地化支持。为此,您需要将 Form Localized 属性切换为 true。假设您提供了阿拉伯字符串,则在完成英语布局并将翻译放置在适当的位置后,您需要将表单的 Language 属性从(默认)切换为阿拉伯语。这是最简单的方法。在使用阿拉伯语时,您还需要将 Form 的 RightToLeft 属性切换为 Yes,并将 RightToLeftLayout 切换为 True。
如果你做得正确,你会看到该形式是镜像的。这是理想的情况,不要惊慌。

更糟糕的是您偶尔需要显示消息框。这里的问题是,根据您使用的语言类型,您实际上需要以不同的方式执行此操作,因为阿拉伯语(和其他 RTL 语言)要求使用 RTLReading 常量:

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);
}

这就是高级别的.. 。

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.

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.

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...

放我走吧 2024-12-05 18:46:57

您可以使用 2 个资源文件,一个是英语,一个是阿拉伯语,当您选择语言时,应用程序会选择要使用的资源文件。

you can use 2 resource files one in English and one in Arabic and when you select the language the application selects what resource file to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文