Question

I am currently working on localizing a Form. However I am somewhat confused as to how one correctly does this.

I thought it would be possible to export control properties to a resource file automatically, but it seems this is a manual task.

My current approach is to add all the Control Properties which are of type String and are writable to the resource file. This by recursively enumerating all the controls and child controls on the form and Reflecting the properties.

But this seems somewhat complicated, and I wonder how other people do this.

So my question: What is the best-practice in terms of using a resource file for Control Text Localization?

Edit: I see what I am doing wrong. I thought the Displaytext would automatically be copied into each resource file. However it seems only the fields that have changed are copied.

So basically, I set the language to a certain setting, change the DisplayText for all the controls, and when I change the language back to (default), the changed are saved.

Thanks for any/all comments.

Was it helpful?

Solution

Well, actually localizing a form is not that hard. You set the "Localizable" property to "true". This causes all localizable properties of controls on the form to be migrated into a resource file. The current resource file is the locale-independent one. You can then select another language in the Form's properties and replace all control captions and texts with their translated variants. This causes the appropriate locale-dependent resource file to be created and used.

You can select the language in which the interface is displayed by setting the CurrentCulture and CurrentUICulture properties on Thread.CurrentThread:

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-GB");

The interface wil adapt accordingly.

OTHER TIPS

It does this already.

Turn on Localizable in the Form or UserControl designer.

Now change you Language (also in designer), and the appropriate langXXX.resx is automagically created.

You just need to make the form localizable (in the properties panel, set Localizable to true). Then you just need to select the language for which you want to localizable. All necessary resource files are generated automatically

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top