Localization of controls within a form

Answered
0
0

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?

Best, Harald

  • You must to post comments
Best Answer
0
0

Hi Harald,

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.

  • You must to post comments
Best Answer
0
0

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.

  • You must to post comments
0
0

Hi Luca,

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 …

Best, Harald

 

  • Luca (ITG)
    The behavior is standard. It’s not possible to guess where a developer has placed the localization of resources. It’s not just the labels in the designer. Most applications create or modify the UI dynamically. Switching a language is an operation that normally requires a log out.
  • Tiago (ITG)
    Switching language on logout/login is the standard way of doing it, both on Wisej as in WinForms. If one wants to offer online language change, one must implement a customized strategy. One could also databind the Text properties to properties of a translation object. But no strategy is perfect and even using databinding there might be problems, for example translating ErrorProvider messages.
  • Tiago (ITG)
    Hi Harald. Have a look at https://github.com/iceteagroup/wisej-examples/tree/master/RuntimeLocalization project. It includes a class that uses reflection to change localized resources in runtime. No need to close and re-open the Form.
  • Harald Zimmerer
    Hi Tiago, thank you for your hint … I’m going to have a look at your code – with pleasure because this would be a great feature for localizing a form :-) . Best, Harald
  • You must to post comments
0
0

Hi Harald,

Thanks for letting me now the translation feature was broken. I broke it when I changed MainForm to Page (it was Form previously). It’s fixed now.

  • You must to post comments
0
0

The expected behavior in WinForms and Wisej is to apply the localization at creation time.

  • You must to post comments
0
0

Hi Tiago,

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 1.4.86.0?

Best, Harald

Attachment
  • Tiago (ITG)
    Blimey, you are right. It doesn’t work as it should any longer. I’m on it.
  • You must to post comments
0
0

Hi Luca,

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.

Best, Harald

 

Attachment
  • You must to post comments
0
0

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:

https://wisej.com/docs/html/Localization.htm

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.