Problems with Multilanguage

Problems with Multilanguage

Post by spig.marc » Mon, 02 Apr 2007 21:06:56


Hi to all!,

I've downloaded .net Framework SDK 2.0 and I have VB.NET2005 Express
Edition, I would like to create multilanguage systems that changes
with radio button.
With Windows Localization Resource I changed the label of my
FrmMain.vb! and created automaticaly FrmMain.en.resx.
When i lunch the command in FrmMain_load()
...
Thread.CurrentThread.CurrentUICulture = New CultureInfo("en")
...
Doesn't happen anything!

That's wrong?

Thanks

Marco
 
 
 

Problems with Multilanguage

Post by Chris Tayl » Tue, 03 Apr 2007 01:30:10

Hi,

After setting the thread culture you will need to re-apply the resources to
the controls on the form. To get you started a routine like the following
should work. Please note that this does not catter to the more complex
scenarios where you might have child forms etc. This is just to get you
started.

public void ApplyResources()
{
ComponentResourceManager resources = new
ComponentResourceManager(typeof(Form1));
resources.ApplyResources(this, "$this");
ApplyResources(this, resources);
}

public void ApplyResources(Control control, ComponentResourceManager
resources)
{
foreach (Control child in control.Controls)
{
resources.ApplyResources(child, child.Name);
if (control.HasChildren) ApplyResources(child, resources);
}
}

private void rbDefault_CheckedChanged(object sender, EventArgs e)
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en");
ApplyResources();
}

private void rbAfrikaans_CheckedChanged(object sender, EventArgs e)
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new
CultureInfo("af");
ApplyResources();
}

Hope this helps

--
Chris Taylor
http://www.yqcomputer.com/