[Home]BiDi

MeatballWiki | RecentChanges | Random Page | Indices | Categories

Arabic and Hebrew are locales that have special concerns. Traditionally, they layout their text right-to-left on a page. However, since computers were designed by English speakers, computers "naturally" layout text left-to-right. Moreover, since most software is in English and many words in technical language are English, it is common practice to intersperse English with Arabic or Hebrew. This means that there are left-to-right strings embedded in the right-to-left text stream. Hence, Arabic and Hebrew are known as bidirectional, or simply BiDi, locales.

Now, you may think that it would be a simple matter of switching modes when necessary. However, that is not true. Internally, it is still important to represent text as a stream of characters. So, the first character is placed at the first position in a string, the second in the second and so on. It is also important to represent numbers in the same way in the string, with the most significant digit first, in order to utilize existing string manipulation algorithms. However, in Arabic and Hebrew, numbers are written with the least significant digit "first" (on the right—so they actually look the same as English). Thus, even without English, Arabic and Hebrew would be bidirectional.

At first blush, since the text stream’s orientation is not changed, the problem of right-to-left versus left-to-right would then seem to be just a display problem. As the display reads the text buffer, it layouts the characters appropriately. However, it quickly becomes an input problem as soon as text editing becomes necessary. Just think of how the cursor would track. At first it would move right to left across Arabic, on the left side of each character. Then, when it crossed into English text, it would move far to the left to be on the right side of the first English character. See Figures 1 and 2 (Arabic in capitals).

Figure 1. Moving to the next character in Arabic.

Figure 2. Moving to the next character from Arabic to English.

This is further complicated with mouse input, as the third character from the "end" (or left) of the string visually is not necessarily the third character from the end of the string in memory. So, selection, hit testing, mouse movement, and so on needs to be calculated carefully.

Also, while it is possible to embed English in Arabic, it is also possible to embed Arabic in English. While the distinction isn’t obvious, it is important. If the main language is Arabic, the text is globally oriented right-to-left, whereas if it were English, the text would be globally oriented left-to-right. Global orientation is the direction of the sentence. It orients the chunks of Arabic and English relative to each other. See Figures 3 and 4 to see how the string "ARABICenglish" (Arabic in capitals) would display differently in the two global orientations.

Figure 3. "ARABICenglish" globally oriented right-to-left.

Figure 4. "ARABICenglish" globally oriented left-to-right.

Extending this further, it is important to lay the graphic user interface components out in the global orientation in order to be consistent. Imagine an English dialog that is entirely right justified. It would look very strange. Similarly, a left-justified dialog would look strange to someone reading right-to-left. So, it is necessary to flip the dialog horizontally. This is known as GUI mirroring.

Figure 5. GUI mirroring. The dialog on the left is left-to-right global orientation; the dialog on the right is right-to-left.

In Figure 5, we see what GUI mirroring would look like. Once again, we use the familiar string "ARABICenglish". On the left, the dialog is oriented as if it were English—that is, left-to-right global orientation. The title is left justified, the title buttons are on the right, the OK and Cancel buttons are to the right, etc. However, on the righthand dialog—which is right-to-left globally oriented—everything looks reversed. The title is right justified, the title buttons are on the left, the OK and Cancel buttons are to the left and switched around. Notice also that the radio button’s label now appears to the left of its button. And that the cursor appears to be in the middle of the string in the edit box, although it is really semantically at the end.

In order to properly support BiDi, all the above must be taken into consideration.

|CategoryGlobalization|


Discussion

MeatballWiki | RecentChanges | Random Page | Indices | Categories
Edit text of this page | View other revisions | Search MetaWiki
Search: