docs

Right-to-Left Support in Controls

OpenUI5 supports right-to-left directionality (RTL) in controls.

Unicode defines the direction in which a browser arranges characters to form words. CSS 2.1 also provides a direction property. The dir attribute in HTML overrides the overall direction of blocks and influences the text alignment, if not set explicitly. The lang attribute does not influence the text direction.

It is possible to use document.dir for text direction. The browser supports it and it can be set in the bootstrap. The <bdo> tag in HTML is used to control the bidirectional algorithm. This means that the character order is then not reversed if RTL and LTR words are mixed.

In a nutshell, this means the following:


General Algorithm

If OpenUI5 is configured for RTL mode, the OpenUI5 core performs the following steps:

  1. dir="rtl" is set on the HTML tag.

    Note:

    The W3C officially recommends using the HTML attribute instead of the CSS properties as directionality is determined by content and has nothing to do with the presentation. Another reason is that CSS properties can be ignored. They also recommend using the <HTML> tag instead of the <BODY> tag.

  2. The respective library-RTL.css files are loaded.

  3. The CSS generator includes an RTL flipping algorithm. This algorithm performs the following changes:

    • border-left: is converted toborder-right:, padding-left: is converted to padding-right:, float:left is converted to float:right and so on.

    • If the img-RTL folder contains any images, their URL paths inside the library-RTL.css file are rewritten as they are considered to be mirrored versions of images with the same name in the img folder.

      Note:

      If images need to be mirrored, you need to manually provide the correct RTL version of the image and save it under the same name in the corresponding subfolder within the img-RTL folder. Otherwise, ensure that the folder contains no image with the same name.