Skip to content

Right-to-left languages: what the interface needs before Arabic, Hebrew or Persian can ship #1395

Open

Description

@nledford

Summary

#1360 adds Arabic. Trying it locally showed that a right-to-left language needs more than a catalog: text comes out with its words in reverse order, and nothing mirrors. Most of that is in egui and in how the interface is painted, not in #1360. This issue lists what I found, so the work can be split and so a decision can be made on the two large parts (bidi and mirroring) before more translations for Arabic, Hebrew or Persian arrive.

Nothing here affects the languages LightCraft has today.

How I know

  • Add Arabic (العربية) interface translation #1360 at 3195d9db, merged locally with my open pull requests, stubbed until it compiled (details in my comment there), then headless snapshots of the library, Edit, Info, Settings and Export in Arabic and English.
  • egui / epaint 0.36.2 (the version in Cargo.lock), read in source.
  • Counts below are git grep over crates/ui-egui/src on main at 701f78ea, tests left out. They size the work; they are not a list of defects.

Blocking: Arabic cannot be read without these

  1. No bidi reordering in text layout. epaint shapes each run of one font and places runs left to right in logical order (epaint-0.36.2/src/text/font.rs:829, "TODO: heed bidi characters"; text_layout.rs:1366). Letters inside an Arabic word join and are ordered correctly. But a space, a digit or a Latin letter falls back to Inter and starts a new run, so the words of every Arabic sentence are drawn first-word-leftmost: "كل الصور" has كل at the left. Punctuation and brackets land on the wrong side for the same reason.
    • Needs: the Unicode bidi algorithm applied before layout (in a text helper of ours, or upstream in egui), with a base direction per language.
  2. No global layout direction. egui 0.36.2 has Layout::right_to_left per Ui, and nothing for a whole context; egui::LayoutDirection and Context::set_layout_direction, which Add Arabic (العربية) interface translation #1360 calls, do not exist.
  3. Much of the interface is painted at positions worked out by hand, which no layout flag reaches: about 205 places compute an x from a rect's left() or right() plus an offset, 56 use a fixed Align2::LEFT_* / RIGHT_* anchor, and 28 lay out with a hard-coded right_to_left(…).
    • Needs: a decision on how to mirror (a start/end helper in the theme that every painted row goes through, instead of left/right), and then a pass over panels, rows, sliders and dialogs.

What should not mirror (to decide once)

  • The photo, the crop and mask overlays, the histogram and the tone curve.
  • Marks over a photo (flags, stars, badges) and the Before / After labels: arguably fixed to the photo's corners.
  • Sliders: the direction of increase, and the side the value sits on.
  • The filmstrip and grid order (reading order of photos).

Smaller things, each its own change

  • Numbers inside right-to-left text. Once bidi exists, a leading sign or a unit moves: "−1.50", "+11", "1/500 s · f/8 · ISO 200 · 135 mm", "12 of 340", "24–70 mm", dates. Each needs an isolate (FSI…PDI) or a left-to-right mark around it. Today they read correctly only because nothing is reordered.
  • Typed numbers. A value typed with Arabic-Indic or Persian digits (١٫٥) is not read as a number.
  • Strong text has no weight in Arabic. The semibold family has no Arabic face, so a heading or the chosen tab is drawn regular beside bold Latin. craft-fonts ships Noto Sans Arabic as a variable font, so a heavier instance may be enough.
  • Glyphs. Noto Sans Arabic has no ▸ or ▾; i18n::tests::catalog_characters_are_paintable and translated_catalogs_do_not_use_missing_menu_triangles catch this in a catalog. Arrows that mean "next" or "back" (about 90 string literals hold ▸ ◂ ← → ‹ ›) need to point the other way when mirrored.
  • Arrow keys. Seven places read ← and →. In a mirrored row they should swap; in the photo (previous / next) they probably should not.
  • Text cut or split by hand. Anything that cuts a string by char, or draws one word as several pieces of text (a highlighted match, for example), breaks joining letters and combining marks. Cut on grapheme clusters, and draw a highlight as a rectangle behind one laid-out run.
  • Format templates. The English plural-suffix pattern (photo{}) does not fit Arabic's six plural forms; docs/localization.md covers hiding the suffix with {:.0}, but a count-dependent word needs more than that. Dates need a template per language (Add Arabic (العربية) interface translation #1360's gives "الاثنين، 6 4 2026", the month as a bare number).
  • Small sizes. Arabic at the 10 and 11 pt sizes looked small to me beside Latin; a native reader should judge whether a script needs its own sizes.
  • Tests. A headless snapshot per right-to-left language of a few fixed views, read by a native speaker once, would catch regressions that no assertion on widths does.

What I am doing about it

In my own open pull requests, since they touch the same text code:

I have not started on bidi or mirroring, and would not without a maintainer's decision on the approach: both reach into every panel.

Suggested order

  1. Decide: bidi in our own text helper, or wait for / contribute to egui.
  2. Decide: the mirroring rule (start/end helper) and the list of what does not mirror.
  3. Land the small independent items above; they are useful now.
  4. Then a right-to-left language can ship. Until then, a catalog like Add Arabic (العربية) interface translation #1360's could be kept ready but not offered in the language list.

Related: #1360 (Arabic), #648 / #1184 (templates and contribution docs, for where a "new language" checklist could live).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions