juliodiz
asked on
Multi-Language C#
Hello,
How can i create a button to multi-laguage?
I create a form in pt-BR, en-US and es-ES.
I need to when i click the button language change the form.
Thanks!
How can i create a button to multi-laguage?
I create a form in pt-BR, en-US and es-ES.
I need to when i click the button language change the form.
Thanks!
http://www.dotnetcurry.com/ShowArticle.aspx?ID=174&AspxAutoDetectCookieSupport=1
ASKER
So i try this one, but inside the groupbox the label doesnt change
private void RefreshResources(Control ctrl, ComponentResourceManager res)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, CurrentLocale);
foreach (Control control in ctrl.Controls)
RefreshResources(control, res); // recursion
ctrl.ResumeLayout(false);
}
// calling
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(this, "$this");
RefreshResources(this,resources);
ASKER
Thanks, but the CurrentLocale does not exist in the current context.
How i get the current locale?
How i get the current locale?
try using this instead
CultureInfo.CurrentCulture
CultureInfo.CurrentCulture
ASKER
No, nothing change. I click and nothing happens
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Login));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
private void RefreshResources(Control ctrl, ComponentResourceManager res)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, CultureInfo.CurrentCulture);
foreach (Control control in ctrl.Controls)
RefreshResources(control, res); // recursion
ctrl.ResumeLayout(false);
}
private void button5_Click(object sender, EventArgs e)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Login));
resources.ApplyResources(this, "en-US");
RefreshResources(this, resources);
}
ASKER
This is the correct, sorry
private void RefreshResources(Control ctrl, ComponentResourceManager res)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, CultureInfo.CurrentCulture);
foreach (Control control in ctrl.Controls)
RefreshResources(control, res); // recursion
ctrl.ResumeLayout(false);
}
private void button5_Click(object sender, EventArgs e)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Login));
resources.ApplyResources(this, "en-US");
RefreshResources(this, resources);
}
private void button4_Click(object sender, EventArgs e)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Login));
resources.ApplyResources(this, "pt-BR");
RefreshResources(this, resources);
}
ASKER
I click and anthing happens, dont change to us-EH,
any idea?
any idea?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok! Thanks again
But now error in the:
RefreshResources(control, res); = No overload for method RefreshResource
and
ChangeLanguage(this, "en-US"); = No overload for method ChangeLanguage
But now error in the:
RefreshResources(control, res); = No overload for method RefreshResource
and
ChangeLanguage(this, "en-US"); = No overload for method ChangeLanguage
ASKER
OK!
Now works!
Thank a lot! realy, thanks.
Now works!
Thank a lot! realy, thanks.
private void ChangeLanguage(string lang)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Login));
resources.ApplyResources(this, "$this");
RefreshResources(this, resources, lang);
}
private void RefreshResources(Control ctrl, ComponentResourceManager res, string lang)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, new CultureInfo(lang));
foreach (Control control in ctrl.Controls)
RefreshResources(control, res, lang); // recursion
ctrl.ResumeLayout(false);
}
private void button5_Click(object sender, EventArgs e)
{
ChangeLanguage("en-US");
}
ASKER
But, how i can pass this language to the next form?