Arabic language localization in a english desktop C#.net application

后端 未结 2 1280
北海茫月
北海茫月 2020-12-21 16:08

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 pl

相关标签:
2条回答
  • 2020-12-21 16:26

    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.

    0 讨论(0)
  • 2020-12-21 16:29

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

    0 讨论(0)
提交回复
热议问题