2k views
in Embedded Wizard Studio by
My Embedded Wizard project have three languages to user select, English, Arabic, Hebrew. What can I do to do this?

Do it like below is OK?

var Core::Root r = GetRoot();
r.Language = Arabic;

1 Answer

0 votes
by

First of all, let me refer to the example 'StringTable' that is described in detail in the article 'Excel String Table Import': This sample application contains a couple of strings to display the 7 weekdays and a couple of buttons to change the currently active language.

When the user presses a language button, a signal is sent to the slot method 'LangButtonPressed'. Within this method you can find the following implementation:

/* determine the button that sends the signal */
if      ( sender == ButtonDE ) language = German;
else if ( sender == ButtonIT ) language = Italian;
else if ( sender == ButtonFR ) language = French;
else if ( sender == ButtonNL ) language = Dutch;
else if ( sender == ButtonGR ) language = Greek;
else if ( sender == ButtonJP ) language = Japanese;
else if ( sender == ButtonKR ) language = Korean;
else if ( sender == ButtonCN ) language = Chinese;
else language = Default;

As you can see, the switching of languages can be achieved by assigning the new value to the 'language' variable. The variable 'language' is a global built-in variable, which contains the currently active lanugage and that can be used to change it.

If you want to change the currently active language during design time, in order to see your user interface with a certain language selection directly within the Composer window, just select the desired language directly within the corresponding drop-down-list:

All details concerning language selection are described within the 'Chora User Manual', chapter 'Language Selection'.

by
All variables and properties that are initialized with multilingual string constant, will be reinitialized automatically after the language has changed.
Of course, if you have done the assignment by using your own method, Embedded Wizard does not generate code for doing a certain re-initialization.
In this case, you can implement a ReInit() re-constructor:
The definition of a re-constructor is similar to an ordinary method. A re-constructor always has the name 'ReInit', expects no arguments and may not return a value, for example
method void ReInit()
{
  Caption = GetCaptionForCurrentLanguage();
}
The re-constructors are automatically invoked by the Chora Runtime Environment when the currently selected language changes to give the object the chance to request additional language dependent resources, etc. It is not necessary and, in fact, unadvisable to call the re-constructors directly from the Chora code!
Additionally, please set the attribute 'MultiLingual' to 'true', in order to get the ReInit() method called after the language has changed.
For more details, please see 'Chora User Manual', chapter 'ReInit re-constructors'.
by
I am still having issues getting the ReInit to work.  The method is called as expected but I can't seem to trigger things (like a menu panel full of menu items) to refresh themselves to the language specific value that exists.  Is there some special way (method) to trigger a view like this to redisplay its text (which should now show the language alternate)
by
also - all of the strings in the menu and menu items are string constants with multilingual definitions
by
the ReInit method for my menu panel contains this code:

MenuItemMain.Caption = APP_SPECIFIC_RESOURCES::MAIN_MENUITEM;
MenuItemCal.Caption = MenuItemCal.CaptionText.String ;

This causes the MenuItemMain  caption text to change (OnSetCaption updates the captiontext)  immediately on a language switch but does not change the MenuItemCal caption.

I was hoping to find a way to do this without knowing the name of the current string constant being shown as the caption text. Which is why I tried the line above with the cal MenuItem  as well as several variations.
by
Concerning the 'trigger to update': There is no need to trigger a view to update - as soon as properties have changed (e.g. by assigning a new text) the view will update automatically.
Concerning the re-init: Maybe this is related to the initialization order (Z-order of the members within your component). Without seeing your code, its difficult to create a correct answer...
But maybe there is a more pragmatic approach: When you assign the different string constants directly within the Inspector to the text properties of your elements, Embedded Wizard takes care for a proper re-initialization. And there is no need for you to write code manually.
The Re-Init constructor is only needed in those cases, where you need to determine some language-dependent information during runtime (e.g. by calling your middleware).

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

...