2
votes

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.

2
You're asking for a pony. Well, mechanical turk. Localization is well supported in .NET but you don't give any hint what kind of GUI you use. Silverlight, ASP.NET, Winforms, WPF, it matters. You also cannot ignore that Arabic is rendered right-to-left.Hans Passant
By desktop you mean standard WinForms, right?Paweł Dyda

2 Answers

6
votes

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

4
votes

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.