Mulilanguage Windows Application

E

Ehab Zaky

Dear All,

I'm developing a Multilanguage application using C# that supports English
and French and Arabic.
I have created the Forms with the default language and changed the language
to each of the languages that I want to support and do any locale specific
changes. Now I have each Form with all its resources needed for all
languages I want to support.
I want to put menu items that switch the application interface
instantaneously between languages that the application support without
restating the application.

I have tried to change the current thread CultureUI to the new culture then
call the InitializeComponent() method but it gives strange results.

How could I do that??
 
D

Derrick [MCSD]

Hi Ehab,

The UI culture must be set (from an app.config file, or in an initialization
form) before a form displaying any localized resources is loaded . This
allows the appropriate resources to be retrieved during the actual loading
of the localized form.

HTH,
Derrick
 
J

Jacky Kwok

Ehab said:
Dear All,

I'm developing a Multilanguage application using C# that supports English
and French and Arabic.
I have created the Forms with the default language and changed the language
to each of the languages that I want to support and do any locale specific
changes. Now I have each Form with all its resources needed for all
languages I want to support.
I want to put menu items that switch the application interface
instantaneously between languages that the application support without
restating the application.

I have tried to change the current thread CultureUI to the new culture then
call the InitializeComponent() method but it gives strange results.

How could I do that??


You should not call the InitializeComponent() directly.

InitializeComponent() will create and initizlize all controls.

You just need to reload all the resourse strings.

You can refer your InitializeComponent() function

e.g. your InitializeComponent() has

private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(FormXXXX));

this.label1 = new System.Windows.Forms.Label();
this.label1.AccessibleDescription =
((string)(resources.GetObject("label1.AccessibleDescription")));
this.label1.AccessibleName =
((string)(resources.GetObject("label1.AccessibleName")));
.......
this.label1.Text = resources.GetString("label1.Text");
.......
}



Then you can implement a function

void ReloadResource()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(FormXXXX));

this.label1.Text = resources.GetString("label1.Text");
.......
}

i.e. your function just need to reload the string with Multilanguage
localization necessary.


Then, after you set the thread CultureUI , call the ReloadResource().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top