i am currently using this loop to translate my winforms program to different languages using google translate api:
foreach(Control c in this.Controls)
{
//translate labels, buttons and tabpages for now...
if(c.GetType() == typeof(Label))
{
string old = c.Text;
c.Text = TranslateTextToCustomLanguage(c.Text, currentLanguageCode, languageCode);
Console.WriteLine("successfully translated " + old + " to " + c.Text);
}
else if (c.GetType() == typeof(Button))
{
string old = c.Text;
c.Text = TranslateTextToCustomLanguage(c.Text, currentLanguageCode, languageCode);
Console.WriteLine("successfully translated " + old + " to " + c.Text);
}
else if (c.GetType() == typeof(TabPage))
{
string old = c.Text;
c.Text = TranslateTextToCustomLanguage(c.Text, currentLanguageCode, languageCode);
Console.WriteLine("successfully translated " + old + " to " + c.Text);
}
}
but this loop does not include controls in panels and tabpages
can i make a loop that also includes all the children?