The Motif Toolkit is a library that defines a set of widgets with their corresponding functions. The Bidirectional Motif toolkit provides a convenient way of creating Arabic/Hebrew graphical user interfaces.
The additions in libXm.a for Arabic/Hebrew fall into two categories. There are changes which deal with the reserved geometry (right-to-left screen orientation). These affect a large number of widgets and gadgets. Whereas other changes deal with inputting bilingual text and supporting bidirectional functionality (that is, character shaping, symmetric swapping, etc.). The later changes affect mostly Text widgets.
Since the additions in libXm.a for Arabic/Hebrew fall into two categories, a number of additional resources were incorporated in the toolkit. In the following section is a description of these resources, their names and their possible values.
These resources control the geometry of the screen as well as the bidi behavior of widgets. These can be set, like other resources, either from a resource file or from inside a program (the XtSetArg function). Depending on the way you choose to set them, the way their names and values are written will vary accordingly.
Refer to the Layout Services in the libi18n.a file for more information on these values.
If the resources are set from a resource file:
|Resource Name||Values||Effect||Default Values|
|textMode||text_mode_implicit||Text display is in implicit mode||text_mode_implicit|
|text_mode_visual||Text display is in visual mode|
|text_mode_explicit||Text display is in explicit mode|
|layoutDirection||right_to_left||Global orientation is set Right to Left.||left_to_right|
|left_to_right||Global orientation is set Left to Right.|
|csdMode (character shaping)||csd_mode_auto- matic||Automatic shaping mode||csd_mode_automatic|
|csd_mode_pass- thru||Passthru shaping mode|
|csd_mode_initial||Characters shaped in initial form|
|csd_mode_middle||Characters shaped in middle form|
|csd_mode_final||Characters shaped in final form|
|csd_mode_isolated||Characters shaped in Isolated form|
|nssMode (numeric shaping)||nss_mode_bilingual||Numbers represented upon context||nss_mode_bilingual|
|nss_mode_arabic||Numbers represented in Arabic||true|
|nss_mode_hindu||Numbers represented in Hindu||false|
|nss_mode_pass- thru||Numbers in passthru mode||false|
|symmetricSwap||true||Symmetric swapping on|
|false||Symmetric swapping off|
|expandTail||true||Seen Family shaped on 2 cells|
|false||Seen Family shaped on 1 cell|
|textCompose||true||Diacritics above consonants|
|false||Diacritics beside consonants|
If the resources are set through the widget's argument list (using the XtSetArg function):
|XmNtextMode||XmTEXT_MODE_IMPLICIT||Text display is in implicit mode|
|XmTEXT_MODE_VISUAL||Text display is in visual upon context mode|
|XmTEXT_MODE_EXPLICIT||Text display is in explicit mode|
|XmNcsdMode||XmCSD_MODE_AUTOMATIC||Automatic shaping mode|
|XmCSD_MODE_PASSTHRU||Passthru shaping mode|
|XmCSD_MODE_INITIAL||Characters shaped in Initial form|
|XmCSD_MODE_MIDDLE||Characters shaped in Middle form|
|XmCSD_MODE_FINAL||Characters shaped in Final form|
|XmCSD_MODE_ISOLATED||Characters shaped in Isolated form|
|XmNnssMode||XmNSS_MODE_BILINGUAL||Numbers represented upon context|
|XmNSS_MODE_ARABIC||Numbers represented in Arabic|
|XmNSS_MODE_HINDU||Numbers represented in Hindu|
|XmNSS_MODE_PASSTHRU||Numbers in passthru mode|
Note: Take care that another resource not related to the added Arabic/Hebrew support still needs to be set, namely the fontList resource. The font list must include an Arabic/Hebrew font name so that Arabic/Hebrew characters can be created.
The following example creates a text widget after setting the layout direction right-to-left and the text mode to implicit. This can be done either from a resource file:
*XmText*layoutDirection :right_to_left *XmText*textMode :text_mode_implicit
Or, from inside a program:
ArgList args; XtSetArg(args&1brk.0&rbrk., XmNlayoutDirection, XmRIGHT_TO_LEFT) XtSetArg(args&1brk.1&rbrk., XmNtextMode, XmTEXT_MODE_IMPLICIT); XmCreateTextWidget(parent_widget, text_widget_name, args, 2);
The XmText widget class is affected by all the bidi resources discussed previously. It can display text in three modes: implicit, explicit and visual. It supports character and numeric shaping in addition to a couple of miscellaneous functions: symmetric swapping and the special handling of the seen family. Furthermore, the text widget supports bidi key combinations, these are the same as the ones used by the aixterm Command. The XmText widget also reacts to the layoutDirection resource. See the following section entitled: "Effect of LayoutDirection on Motif Widgets and Gadgets."
The XmTextField widget is affected by all the bidi resources. It behaves like the text widget but it does not handle the explicit text mode.
The XmLabel and XmGadget widget class is affected by the textMode resource in addition to the Primitive (or layoutDirection) resource. See the following section entitled: "Effect of LayoutDirection on Motif Widgets and Gadgets." Setting Implicit Control Support (ICS) and automatic shaping of the label string overrides the default resource to implicit text mode. Otherwise, the label string displays in regular motif behavior.
The XmList widget class is also affected by the textMode resource in addition to the layoutDirection or Primitive resource like the XmLabel widget class. Once the text mode is set to implicit, the Transformation mechanism applies to the list widget. Otherwise, the list item string displays in regular motif behavior.
The layoutDirection resource in the primitive widget affects the following Motif widgets and Gadgets to enable the bidirectional layout:
|CascadeButton||Reverse side of cascade graphic|
|Command||Place prompt string at right hand side, with default of "<"|
|DrawButton||Show accelerator at left of label|
|FileSelectionBox||Lay buttons out from right-to-left|
|Label Widget||Locate accelerator text to left of label text|
|List Widget||Force string direction to right-to-left|
|MessageBox||Lay buttons out from right-to-left|
|PushButton||Show accelerator at left of label|
|RowColumn Widget||Layout subordinates from right-to-left for all menu types|
|Scale||If XmNorientation is XmVertical, and XmNshowValue is|
|ScrolledWindow||Propagate direction to subordinates|
|ScrollBar||If XmNorientation is XmHORIZONTAL, default|
|SelectionBox||Lay buttons out from right-to-left and align labels on|
|ToggleButton||Show accelerator at left of label|
|Text widget||Force text orientation to right-to-left|
This section provides an example of how to localize the xmeditor file in /usr/sample for Hebrew and Arabic. The Arabic locales are ar_AA and Ar_AA. The Hebrew locales are Iw_IL and iw_IL.
A translated version of the xmeditor file is also supplied. You can compare your changed version of the file to the translated version.
Enter the following command to make sure that the Arabic/Hebrew locales are installed:
If the categories are not set, the locale may not be installed. Use the SMIT Manage Language Environment menu to install the locales.
setlocale(LC_ALL , "");
fontList: -dt-interface system-medium-r-normal-L*-*-*-*-*-*-*:
The whole layout directionality of the xmeditor is reversed and the Latin strings are also reversed. Cascading pop-ups also work from right to left. All text fields open right to left and cursor movement is opposite from the way it is in Latin.
This example describes how to translate the File string in the Main Menu. However, you can use the same process to translate all xmeditor strings.
In this example, the strings are hard coded. However, in many applications the strings you need to translate are in separate files which often allows you to test without recompiling anything.
This section describes how to translate files that are external to the application. This example describes how to translate an external file with the following three names:
FILE HELP MENU
The output of this file as a translated flat file will be in Hebrew or Arabic, where the lower case characters represent Hebrew/Arabic characters:
file help menu
This is how you see the file if you open an En_US aixterm with a Hebrew or Arabic font.
If you open an Arabic or Hebrew aixterm with Arabic or Hebrew font in Implicit mode, the file will display as follows:
elif pleh unem
You can read the strings in the correct order.
If you use an Arabic or Hebrew aixterm to translate the original file, then what you have originally is:
FILE HELP MENU
Now you will start to translate the word FILE. Remove FILE and enter elif by pressing f , then i , then l , then e , which is the correct order of the word in Hebrew or Arabic.
The result will be in what we see in the Hebrew or Arabic aixterm as follows:
elif HELP MENU
If you display the string as a flat file from an En_US aixterm, the file will display in the correct logical character order as follows:
file HELP MENU
The shaping in Arabic is done automatically in the Arabic aixterm and in the Arabic Motif. When you translate using it, it also shapes the characters for Arabic.