Building Mobile Enterprise Applications : webMethods Mobile Designer Native User Interface Reference : Mobile Designer Native User Interface : Adding Support for Right-to-Left Languages
Adding Support for Right-to-Left Languages
The right-to-left (RTL) or left-to-right (LTR) property of a writing system is commonly referred to as its directionality. The NativeUI library has methods to support locales that require right-to-left directionality, such as Hebrew and Arabic.
You can change the directionality of the entire application's user interface to use right-to-left directionality. However, if necessary, an application can use a mix of right-to-left and left-to-right directionality.
Based on the platform on which an application is running, using right-to-left directionality for a user interface might change:
*Default alignment of the NativeUI objects and the text within the objects
*Position of the Back buttons and header menus within the user interface
*Ordering of the columns within the nUITableElement NativeUI object
*Positioning of the carat within the nUIEntryElement NativeUI object
Controlling the Directionality of an Application
The following table describes the NativeUI classes and methods you use to control directionality of an application:
NativeUI Class
Description
nUIConstants
Use the following integers to represent the directionality:
*TEXT_DIRECTION_LTR for left-to-right directionality
*TEXT_DIRECTION_RTL for right-to-left directionality
nUIController
Use the following methods to control the global behavior of the application:
*deviceSupportsAppDirectionality() method
The deviceSupportsAppDirectionality() method indicates whether the platform supports a specified directionality at run time. The method returns true if the platform supports the directionality or false if it does not. The method might return false for one of the following reasons:
*Directionality support for the platform was unavailable through the NativeUI system at the current time.
*The device’s locale settings do not allow a directionality change at the current time.
*The platform does not support the directionality due to other platform-specific issues.
*void setAppDirectionality(int direction) method
Use the void setAppDirectionality(int direction) method to set the directionality. For direction, specify either TEXT_DIRECTION_RTL for right-to-left or TEXT_DIRECTION_LTR for left-to-right.
After changing the directionality, the getAppDirectionality() method immediately reflects the new direction.
At the application’s next update cycle iteration, the NativeUI heartbeat thread invokes CanvasNativeUI.appDirectionalityChanged() with the new direction.
Note:  
You can override the CanvasNativeUI.appDirectionalityChanged () method in your Canvas class if you need to handle changes in the application directionality. Because your initial Canvas class already extends CanvasNativeUI, you do not have to use a separate class to override this function.
*getAppDirectionality() method
The getAppDirectionality() method returns the application’s current global directionality setting, either TEXT_DIRECTION_LTR or TEXT_DIRECTION_RTL.
nUITableElement
Use the following methods to manage the directionality within a nUITableElement NativeUI object:
*Use the setIgnoreDirectionality() method to have the NativeUI system ignore the application’s current directionality setting.
If an application’s directionality is set to right-to-left, by default, the table’s column order is reversed. If you do not want the columns reversed, use this method to ignore the directionality setting for the table columns. For example, you might want this if the table contains images that you want displayed in a specific order regardless of the application’s directionality.
*Use the getIgnoreDirectionality() method to determine whether the application directionality will affect the ordering of columns within the table. The method returns true if column ordering will be affected by the application directionality or false if column ordering will not be affected.
Exceptions to Right-to-Left Directionality
The following lists situations when the application’s directionality is not enforced:
*If an application explicitly sets the position of a NativeUI object, for example, using the setX method, the NativeUI system does not override the position. Similarly, if an application explicitly sets the alignment of a NativeUI object, for example, using the setHAlign method, the NativeUI system does not override the alignment. Only NativeUI objects that have the default position and alignment are subject to directionality changes.
*The nUIWebviewElement and nUIWebView NativeUI objects are not subject to the application’s directionality. To change the directionality of text within these NativeUI objects, use the HTML DIR attribute, for example, <HTML DIR="RTL"> or <p DIR="RTL”>.
*The charting APIs are not subject to the directionality of an application. In most platforms, right-to-left text displays using a right-to-left direction. However, chart and axis reordering is not performed.
Platform-Specific Notes and Issues
When an application uses a right-to-left directionality, how objects in the user interface display depends on the platform's support for right-to-left setups. Wherever possible, the NativeUI system attempts to use the platform-specific conventions for when a device uses a right-to-left locale.
Platform
Notes
Android
*Android version 11 and higher support right-to-left directionality. In previous versions, right-to-left support depends on OEM additions to the Android code base to ensure font availability and right-to-left text rendering.
*The nUICheckboxButton, nUIRadioCheckbox, and nUIDropdownlistEntry NativeUI objects display using left-to-right directionality. Additionally, non-custom dialog boxes, that is, those created using the nUIAlertDialog NativeUI object, might also retain left-to-right alignments.
iOS
*The following NativeUI objects display using left-to-right directionality.
*nUICheckboxButton
*nUIDropdownlistEntry
*nUIRadioCheckbox
*nUINavView
*The buttons within a nUIDialogWindow NativeUI object display using a left-to-right directionality.
Windows Phone
Windows 8
Windows RT
*At this time, Windows Phone, Windows 8 and Windows RT do not support right-to-left directionality.
J2ME (Phoney)
*The NativeUI system attempts to provide directionality features similar to those that other platforms provide. In general, the NativeUI system makes the functionality align with that provided by Android and iOS.
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback