Zombie_002

how can i add a combo box were people select the language they want and it will transform it al into that selected language any help is appreciated thank you

Re: Windows Forms General Multi language help please

frederikm

Hi

you need to do a few things:

- create a new windows project
- add a combobox on the form
- in the form load event handler, place the following code:
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures)) {
comboBox1.Items.Add(culture);
}

- in the combox selected index changed event handler place the following code:
CultureInfo selected = (CultureInfo)comboBox1.SelectedItem;
if (selected != null) {
Thread.CurrentThread.CurrentUICulture = selected;
}

- add culture specific values for the form text and so on
as per http://msdn2.microsoft.com/en-us/library/y99d1cd3(VS.80).aspx

More information about globalization you can find at:
http://msdn2.microsoft.com/en-us/library/9xdxwwkc(VS.80).aspx

Hope this answers your question, please close the thread if it does






Re: Windows Forms General Multi language help please

Zombie_002

hmm.. didnt help me any but im sure i know someone that might know what to do from there



Re: Windows Forms General Multi language help please

frederikm

hi

It seems that there is a bug related to the resource manager:

http://dotgnu.org/pipermail/pnet-developers/2003-December/000844.html

The reasons are:
1) ResourceManager uses CultureInfo.CurrentCulture, but it should use
CultureInfo.CurrentUICulture instead.
2) The CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture getters
should make an indirection to the Thread.

So, the problem is that while the Thread now has the correct culture, the Resource manager does not update the values on the screen

what you could do is the following:

- add a label to the previous example
- add a private ResourceManager to your form
private ResourceManager _resourceManager = new ResourceManager("rmc", Assembly.GetExecutingAssembly());
- create a satellite assembly as described here:
http://www.codeguru.com/vb/gen/vb_misc/multi-languagesupport/article.php/c5601/
- add the following method to your form
private void Localize(){
this.label1.Text = _resourceManager.GetString(keyOftheLabel);
}
- update the method to set the correct value
CultureInfo selected = (CultureInfo)comboBox1.SelectedItem;
if (selected != null) {
Thread.CurrentThread.CurrentUICulture = selected;
Localize();

}

- see also:

http://msdn2.microsoft.com/en-us/library/system.resources.resourcemanager.aspx

Hope this helps you out