3 min read #OpenCloud#a11y#UX

OpenCloud · Right-to-left

RTL support for Arabic and Hebrew

Arabic, Persian, Hebrew and Uyghur could be selected in OpenCloud, but the interface still ran left to right. Starting with 9.3.0, the whole layout mirrors in these languages, while file names, sizes and passwords keep their reading direction. The implementation is based on logical CSS properties, which extension developers should use as well.

Accessibility is usually about screen readers, contrast and keyboard navigation. But barriers also appear where an interface is built against its users' reading direction. Hundreds of millions of people read and write from right to left, in Arabic, Persian, Hebrew or Uyghur. For them, an interface built from left to right is more than a matter of taste: the eye looks for the start of a line on the wrong side, arrows point the wrong way, and the navigation sits where the eye looks last. Working with such an interface every day means constant translation, which costs concentration and leaves the impression that the software wasn't made for you.

OpenCloud has set out to let everyone work on and share content together, regardless of budget, abilities or corporate accounts, and explicitly including those who are otherwise left out. For people who read right to left, that was only half true so far. Arabic, Persian, Hebrew and Uyghur have been available as languages for a long time. The translated texts also appeared in the right direction. The interface around them, however, stayed European: navigation on the left, sidebars on the right, an arrow pointing right for “next”.

Mirrored layout for Arabic and Hebrew

With OpenCloud 9.3.0, the entire layout flips in these languages. The navigation sits on the right, sidebars slide in from the left, menus open toward the other side, toggles move in the other direction. Icons that express a direction are mirrored, among them back, forward, reply and forward message. Some things deliberately stay as they are, because mirroring would distort them: file names with their extensions, file sizes and link passwords keep their left-to-right reading direction even in the middle of Arabic text. Page navigation in the e-book reader follows the book rather than the interface. Native speakers reviewed the result. The contribution came from the community, from @xhzeem. It touches almost every component of the web interface.

The implementation doesn't need a separate stylesheet for right-to-left display. OpenCloud sets the dir attribute on the document on load and on every language change. All spacing, margins, positions and alignments now refer to the start and end of a line, which the browser places according to the writing direction, instead of to left and right. In the Tailwind classes, ml-2 becomes ms-2 and text-left becomes text-start; in CSS, margin-left becomes margin-inline-start. In left-to-right languages everything looks the same as before. The design system mirrors direction icons with a single class, popovers switch sides, and file names and other technical values sit in their own elements with a fixed reading direction, so the Unicode bidirectional algorithm doesn't mix them up with the surrounding Arabic. Because the solution relies on what browsers provide, it stays correct when new components are added, as long as they use the same logical properties.

Logical properties for extensions

This creates a task for everyone who builds extensions. An extension that brings its own UI and uses physical properties such as ml-2 or left: 0 there stays left to right, out of place in an otherwise mirrored interface. If you use the logical variants and rely on the design system's components for icons and popovers, you get mirroring without any extra code. Since nothing changes in left-to-right languages, the switch carries no risk. To test it, select Arabic or Hebrew in your own settings.

Text that hasn't been translated yet still appears in English and runs left to right.

Sources