C
Christian Schwarz
Hello,
I'm trying to find an easy way to localize control's Text properties.
For instance I could replace the following code:
void InitializeComponents()
{
....
this.m_Label1 = new Label();
this.m_Label1.Text = "Hallo Welt !"
....
}
with this code:
void InitializeComponents()
{
....
this.m_Label1 = new Label();
this.m_Label1.Text = Resource.GetString("Hallo Welt !")
....
}
In which Resource.GetString() is a static function searching the calling
assembly's resources for a translation of "Hallo Welt !" depending on
System.Globalization.CultureInfo.CurrentUICulture.
Unfortunately, editing InitializeComponents() would render the designer
useless. So that method is out of question. The next solution that comes to
mind is to set all translatable text again after InitializeComponents() has
finished. But this is cirumstantial, fault-prone and time-consuming (both,
run-time and design-time).
Another approach would be to extend all standard controls so that they call
Resource.GetString() automatically.
How would you or did you deal with this problem ?
Greets, Christian
I'm trying to find an easy way to localize control's Text properties.
For instance I could replace the following code:
void InitializeComponents()
{
....
this.m_Label1 = new Label();
this.m_Label1.Text = "Hallo Welt !"
....
}
with this code:
void InitializeComponents()
{
....
this.m_Label1 = new Label();
this.m_Label1.Text = Resource.GetString("Hallo Welt !")
....
}
In which Resource.GetString() is a static function searching the calling
assembly's resources for a translation of "Hallo Welt !" depending on
System.Globalization.CultureInfo.CurrentUICulture.
Unfortunately, editing InitializeComponents() would render the designer
useless. So that method is out of question. The next solution that comes to
mind is to set all translatable text again after InitializeComponents() has
finished. But this is cirumstantial, fault-prone and time-consuming (both,
run-time and design-time).
Another approach would be to extend all standard controls so that they call
Resource.GetString() automatically.
How would you or did you deal with this problem ?
Greets, Christian