views:

428

answers:

4

I have to make a multi-lingual desktop application in C# 3.5. I know how to add multilingual text for labels at design time.

But I am unable to find how to make Messagebox and Confirm dialogs multilingual? Do I have to add if/else conditions in code to check the selected language?

Thanks in anticipation!

+2  A: 

You need to move the caption and message strings into resources and then access them via the auto-generated properties on the Properties.Resources class for your assembly.

The main resource file for a project can be created by viewing the project properties and clicking the Resources tab. If you don't already have a Resources.resx for your project, there will be a link on that tab to create one. Once it is created, you can add project-scoped resources such as images and strings.

Jeff Yates
+1  A: 

You should use Resources. (Can be found at Project -> Properties... -> Resources tab)

If you use Resources tab then VisualStudio will create Resources.resx file in Properties folder for you where you can store different type of resources. (e.g. Images, Audio and Strings) You can add any localizable strings there and use them later like Properties.Resources.MyMessageBoxTitle.

Later when you want to add a support for another language you can copy that Resources.resx file and rename it to something like Resources.it-it.resx (or Resources.fr.resx). Resource manager then will automatically load the string from a corresponding resource file. (based on Thread.CurrentUICulture)

Regent
I can create resource files at project level and form level as well. If I add these resource strings in form resource files then how do I access them?
Haris
@Haris, it is not recommended to use form's resources in this way, because they are usually autogenerated by the designer and they are only used in Form's `InitializeComponent` method. After that there is no idealogically good way of getting them. (Besides of creating your own instance of `ComponentResourceManager` of course.)So please prefer project-level resources for your scenario.
Regent
+1  A: 

In the designer, on the parent form or control, there is a property called Localizable, set it to true, then, you can change it's Language property and change labels/move controls around so that the layout fits for that localization.

Doing so will create resource files accordingly.

Dynami Le Savard
A: 

I use resources for message string in message box, but I have problem with their direction. I have to make one of them right to left and in English culture it remains left to right.

Thanks in advance

nasim