Take a Combo Box and add item
Hindi
English
Chinese
suppose there is a Label1 on the Form and its Text Property is= Nagendra
and we want to change its Culture according To Language in
Hindi= नागेन्द्र
Chinies=納根德拉
To do this go on the form and set its Property Localizable =True
Now set the language of Form is Hindi and set Label1.text= नागेन्द्र
Now a new .resx file will be made like Form1.hi.resx

Now set the language of Form is Chinies and set Label1.text=納根德拉
Now a new .resx file will be made like Form1.zh-CHT.resx
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
{
ChangeLanguage("hi");
}
if (comboBox1.SelectedIndex == 1)
{
ChangeLanguage("en");
}
else if(comboBox1.SelectedIndex==2)
{
ChangeLanguage("zh-CHT");
}
}
Here we have used hi is for Hindi,zh-CHT for Chinies it is specific for every Language
HI nagendar,
ReplyDeletehow to get hindi word in for a label in form.hi.IN.resx file,i am geting square boxes.....