Repository navigation
Description
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 grepovercrates/ui-egui/srconmainat701f78ea, tests left out. They size the work; they are not a list of defects.
Blocking: Arabic cannot be read without these
- 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.
- No global layout direction. egui 0.36.2 has
Layout::right_to_leftperUi, and nothing for a whole context;egui::LayoutDirectionandContext::set_layout_direction, which Add Arabic (العربية) interface translation #1360 calls, do not exist. - 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()orright()plus an offset, 56 use a fixedAlign2::LEFT_*/RIGHT_*anchor, and 28 lay out with a hard-codedright_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_paintableandtranslated_catalogs_do_not_use_missing_menu_trianglescatch 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.mdcovers 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:
- Type: an exposure reads one way, and values stand in columns (stacked on #1376) #1377: a shortened file name is cut between grapheme clusters, and a slider's value can be typed in Arabic-Indic or Persian digits. Other number fields (custom crop aspect, the date picker, those on egui's own parser) still read ASCII digits only.
- Settings: the filter finds what is typed, best first, and shows why (stacked on #1326) #1330: the Settings filter marks the letters found with a fill and a line under them, and no longer cuts the word into separately shaped pieces.
- LR-BEHAV-LOCALIZE: strong text is heavier in scripts whose fallback face is a variable font (Arabic) #1397: strong text is heavier in Arabic, from the variable Noto Sans Arabic that craft-fonts already ships.
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
- Decide: bidi in our own text helper, or wait for / contribute to egui.
- Decide: the mirroring rule (start/end helper) and the list of what does not mirror.
- Land the small independent items above; they are useful now.
- 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).
Activity
i18n: read Arabic labels right to left (the visual-order pass, storyt…