View previous topic :: View next topic |
Author |
Message |
Michael Guest
|
Posted: Thu Nov 01, 2007 12:23 pm Post subject: Localization & Visual Inheritance |
|
|
Hi,
I’m having troubles with some resources when using localization and Visual Inheritance.
If I Localize them on the Inherited form to a new Language, those strings get overwritten by the original value in the BaseForm.
If I Localize them on the BaseForm, the Localized values do not persist in the Inherited form.
How do I solve this?
TIA,
Michael |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Nov 01, 2007 10:25 pm Post subject: |
|
|
If you have buttons etc on the base form you should localize them on the base form. If you override the text (or other properties) in a derived form then you will need to localize the overridden properties in the derived form. This is the same as for the standard .NET localization mechanism (ie using Globalizer.NET shouldn't make any difference here)
I've just checked this with one of our VB test projects that uses visual inheritance and it seems to be working as expected.
Are you doing binary localization or source code localization? If you are still having an issue with this maybe you could put together a small sample project that demonstrates the problem and email it to support@infralution.com. This helps a lot in tracking down issues. _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Nov 06, 2007 12:28 am Post subject: |
|
|
Thanks for the sample project - it allowed us to quickly identify your issue. The problem is that you are setting the CurrentUICulture in the derived form Form_Load event. But by this stage the resources for both the base form and the derived form have already been loaded (they are loaded in the designer InitializeComponent method).
If you are going to use a form as the startup object then you need to set the CurrentUICulture before the form (or any of its base forms) call InitializeComponent. Unfortunately VB.NET hides what is going on here. Each form class has a implicit parameterless constructor that calls InitializeComponent. The form constructors are called in order (base constructor first). So you would need to set the CurrentUICulture in the constructor of the base form. You could do this by adding an explicit Sub New eg
Code: | Public Class Form1
Public Sub New()
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("NL")
' This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
End Class |
Probably a better idea however is to click the View Application Events button in the project properties and override the MyApplication.OnStartup method to set the CurrentUICulture. This is called before the Startup form is created. _________________ Infralution Support |
|
Back to top |
|
|
Michael Guest
|
Posted: Fri Nov 09, 2007 11:05 am Post subject: |
|
|
Thanks! |
|
Back to top |
|
|
|