258 views
in GUI Development by
Hi, EW team:

     My project has to support multi-language, and some GUI components have to adapt to the language at the same time. So one style is defined to assist one language. The question is how to refresh current screen fully and immediately on changing language and style from background?

   Thank you.

Best regards.

Stephen.

1 Answer

+1 vote
by
 
Best answer

Hello Stephen,

your question as well the usage of Styles to switch languages are not clear to me. Hopefully you will find the answer in following sections:

Managing localization

Managing variants

Please note, in version <= 12 switching Styles had no update effect on already existing (initialized) GUI components. In version 13, the underlying mechanisms have been redesigned. In version 13, switching a Style may very well trigger an update of already existing GUI components. See React automatically to styles alternation for more details.

Best regards

Paul Banach

by
Hi, Paul:

      The shape of some widgets, whose label shows text which has different horizontal size in different language, has to be arranged depending on the language context. So I decided to use variant and style to manage the geometrical differences accompanying language. My project has to support more than 20 languages.

     By the way, the version of EW in my project is 11. I'd like to know how to refresh languge and style with this version.

 

Best regards.

Stephen
by

Your approach sounds very very laborious. I practice you will need to estimate the space for each Text view and each language. I would recommend a more pragmatic approach to adjust the Text views so that all language variants of the respective texts can be shown without being clipped. It means configure the Text views for their maximum size.

Then configure the Text views to align the text inside its area, for example to center the text or align it to the left/right edge. See also: Align the text within the Text view area.

Also, you can configure the Text view to adjust its size automatically to fit to the displayed content. See also Configure the Text view to adjust its size automatically.

If it is inevitable to have the size/position of a Text view depending on the currently selected language, use a constant for this purpose. Configure the constant to have the type rect. Then initialize all language variant specific values of the contents with the individual position/size values. Finally in Inspector window assign this constant in the initialization of the property Bounds of the respective Text view. In this manner, when the language changes, the language specific value from the constant is used and the Text view adjusts its position/size accordingly.

I hope it helps you further.

Best regards

Paul Banach

by
Hi, Paul:

         Your suggestion has helped us a lot.

         I have another requirement in doubt. I have to implement 2 language subsets, one for Europe and the other for Asia. These 2 subsets do not coexist  in generated code for memory space reason. I wonder how I can manage them both in one project while still be able to generate code separately.

         Thank you.

 

Best regards

Stephen
by

Hello Stephen,

in this case you will need to duplicate the Profile member existing in your project. This results in two profiles. The first you use to generate code for Europe and the second profile for Asia. You could name the profiles accordingly, e.g. Profile_Europe and Profile_Asia.

Then select all Language members which are intended to be used in the Europe language subset. Configure the attribute Generator of the selected members to correspond to the name of the 'Europe' profile. Consequently, the languages are generated only when the profile is used.

Similarly, select all Language members to use in the Asia language subset and configure their attribute Generator to be the name of the corresponding profile.

Please note, the language Default should remain enabled for all profiles. 

With this project, switching the profile will enable/disable the languages.

I hope, it addresses your application case.

Best regards

Paul Banach

by
Hello, Paul:

       Your suggestion is really helpful to us.

       Thank you.

 

Best regards

Stephen
by

Hi, Paul:

      I have been deploying multi-language variants these days as you have suggested. As to the Resource::Font class, it has attributes like FontName, Height, Ranges to configure differently depending on language variant.  In debugging, EW studio gives warning as below. Though I had tried to generate Font Ranges separately for different languages, there are characters shared by different languages, such as a, b, c, d... in English and German. And digit numbers are shared by all languages. How should I do with this difficulty.

     It seems that for Font range setting , there is a pre-assumption that the all language variants in a Font configuration share no character code, otherwise, only one glyph from one language variant will be kept for the shared code, Is it right?

Warning Fonts::TextViewFont.Ranges.English : The glyph range specified in the language variant 'English' of the font resource 'Fonts::TextViewFont' overlaps with the ranges from other language variants. The resulting font resource, however, can contain only one glyph for one character code. This can result in text being rendered incorrectly. Please review the 'Ranges' attribute of the font resource 'Fonts::TextViewFont'.

 

Best regards

Stephen

by

Hello Stephen,

there are characters shared by different languages, such as a, b, c, d... in English and German. And digit numbers are shared by all languages. How should I do with this difficulty.

let me first recommend the section Localize a font resource. In your concrete case ensure that the shared glyphs are specified only in one of the languages, e.g. in the language Default. Even if you later display text in e.g. French, the glyphs specified in Default can also be used. You can imagine the resulting font resource like one big font with glyphs collected from different language variants. In this resulting font resource each character code corresponds to exact one glyph regatdless of from language variant iot has been collected.

Note: in the recent version 14, we have modified this behaviour. In version 14, it is very well possible to specify for different languages different glyphs for one and the same character code. The glyph selection occurs then at the runtime depending on the currently selected language. In version <= 13 the currently selected language had no effect on the glyph selection. See also Release Notes: Improvement of localization functionality.

Best regards

Paul Banach

by
Hi, Paul:

       Thanks for answering.

       Now I see that my trouble can be overcome by EW 14.

 

Best regards.

Stephen

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...