Dear support team,
at design time I changed the property “text” of a label within a localized form.
After switching the form’s property “Language” to another language, I changed the label’s property “text” and a new .resx file was automatically created.
Whenever I switch the form’s property “Language” between the new an the standard language the label’s text is shown in the correct way – but only at design time. At runtime it doesn’t work … do I really have to change the text properties of controls within a form programmatically by using the RessourceManager?
Have a look at InterwayDocs a WinForms/Wisej application that is translated in 4 languages: en/es/fr/pt.
There is a combo box to choose the language. On the Wisej application, the combo box changes the URL and that triggers the ApplicationRefresh event as Luca said. The ApplicationRefresh handler iterates all forms to force the refresh of translations.
The behavior is correct. Controls are localized on creation, see InitializeComponent(). We are adding an event Application.CultureChanged to let an app decide what to do in case the language changes later. Now you can detect the language change in ApplicationRefresh in case it’s changed by altering the URL. Otherwise it’s not needed since Wisej detects the language from the browser.
the actual behavior is not satisfying – especially for an application containing a language switch control.
A (nice) implementation of this feature would be very laborious (as you can see in InterwayDocs app) – in spite of the event “Application.CultureChanged”.
In the meantime I found a “workaround” for me because I unterstood that closing and reopening of the form produces the translation of the form and all of its controls (InitializeComponent() was a good hint from you) … unfortunately the contents of the controls are lost by simply closing and reopening the current form …
thank you for the example … but also this example does not work as expected, take a look at the screenshot: I switched from Espanol to English and nothing happened (I tried it with Chrome and Internet Explorer). Maybe a bug of the newest version of wisej 22.214.171.124?
sorry that was not the question.
When I switch the language at runtime (with URL or …) the translation of the label (that I have made in design mode) is not shown … the translation of the form’s caption however is shown … it seems to be that the translation of all controls within a form are not switched automatically.
And I found another behaviour: When I start the browser-session with URL “…/?lang=en” (default language otherwise is German) then it works. But when I change the URL to “…/?lang=de” (I do not close the browser’s session before) then the label’s contents are not switched to German.
That’s correct. The Language property in Visual Studio is a design property used to localize the form. It has nothing to do with the runtime language.
At runtime it will use either the language indicated by the browser or indicated by your configuration or forced in the URL:
Please login first to submit.