Skip to content

fix(i18n): lay out a message of Persian or Arabic digits alone back to front (#3404) - #3652

Open
choupeanut wants to merge 2 commits into
opengeos:mainfrom
choupeanut:fix/3404-rtl-digits
Open

choupeanut wants to merge 2 commits into
opengeos:mainfrom
choupeanut:fix/3404-rtl-digits

Conversation

@choupeanut

@choupeanut choupeanut commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

has_rtl, the cheap check in front of visual, fit, the catalog and paragraph, left the Persian and Arabic digits out, though back_to_front (the toolkit's direction guess) reads a line that starts with one as right to left. A message of those digits alone therefore came back unchanged and painted backwards, while the same digits were reversed beside a letter or on a wrapped row of their own.

  • crates/data/src/display_marks.rs: has_rtl now counts those digits, through a small rtl_strong that strong shares, so the checks agree with visual_line.
  • has_rtl_letter (new) keeps the old meaning, a letter of a right-to-left script, for fit_line in crates/ui-egui/src/i18n/rtl.rs: a row that starts with a Latin word ends before a right-to-left letter (it would paint backwards there), but Persian and Arabic digits in such a row read in logical order and stay on it.
  • A single digit is unchanged (a run of one takes no marks); ASCII digits and left-to-right-led lines are unchanged.
  • paragraph now fits and right-aligns a paragraph of digits alone, like other right-to-left text.

Surfaces: the desktop app, the browser and the phone share i18n::visual. The command line, Python, MCP, the Assistant and plugins don't paint text; display text that leaves the screen is put back by logical, covered by a test. No command or parameter changes, no new interface text.

Testing

Tests added in crates/ui-egui/src/i18n/rtl.rs and boundary_tests.rs; each failed on the code before the change.

  • a_message_of_digits_alone_is_put_in_display_form (visual, fit, has_rtl, a single digit, ASCII digits, a multi-line message, a left-to-right-led line, a line with a mark of its data's own)
  • a_message_of_digits_alone_comes_back_in_logical_order (logical round trip)
  • a_latin_row_keeps_the_digits_that_fit_on_it (fit keeps a Persian-digit word on a Latin-led row)

Run: cargo test -p rustgis-ui-egui --lib i18n, cargo clippy -p rustgis-data -p rustgis-ui-egui --all-targets -- -D warnings, cargo fmt --all -- --check. Not run locally: cargo xtask ci or cargo xtask changed, the other crates' tests, the wasm build; CI covers them.

UI evidence

No screenshot was taken, and the change was not checked in the running app: the tests assert the text handed to the toolkit (for example ۱۲۳ becomes ۳۲۱, which the toolkit's back-to-front layout reads back in order). It affects only text made of Persian or Arabic digits alone.

Related issue

Closes #3404

Summary by CodeRabbit

  • Bug Fixes
    • Improved display of Persian and Arabic numerals in right-to-left text, including messages containing only numerals, so they appear in the correct visual order.
    • Improved mixed-direction line wrapping: Latin text stays together with following numerals, while right-to-left words are separated appropriately.
    • Preserved existing display behavior for related text cases.

…o front (opengeos#3404)

has_rtl, the gate in front of visual, fit and the catalog, left those digits out
though back_to_front reads a line that starts with one as right to left.
…opengeos#3404)

fit_line cuts a Latin-led row before right-to-left letters, which paint backwards
there; the digits read in logical order, so only has_rtl_letter ends the row.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Persian and Arabic digits are now recognized as right-to-left for display. A separate function detects right-to-left letters, and row fitting uses that function so digits alone do not trigger an early break. Tests cover digit display, row fitting, and logical-order restoration.

Changes: RTL Digit Display Handling

Layer / File(s) Summary
RTL character classification
crates/data/src/display_marks.rs
Right-to-left detection now includes Persian and Arabic digits. The new has_rtl_letter function detects right-to-left script characters without counting those digits.
Display and row-fitting behavior
crates/ui-egui/src/i18n/rtl.rs, crates/ui-egui/src/i18n/boundary_tests.rs
The UI re-exports has_rtl_letter and uses it when fitting rows. Tests cover Persian and Arabic digit display, digits remaining with Latin text, and logical-order restoration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • #3278 — This PR adds a logical-order round-trip test for digit-only messages, but does not address the issue’s other cases, including Latin runs.

Possibly related PRs

  • opengeos/RustGIS#3401 — It changes the same display logic and functions involved in RTL classification.
  • opengeos/RustGIS#3286 — It changes output-boundary handling through visual and logical, which this PR also tests.

Suggested reviewers: jgregoriorincon, elpidioassinaturas

Merge Risk: Minimal · up to a4700

This change makes Persian and Arabic digit-only messages display in the same order as the input in right-to-left interfaces. It adds tests for the display, row-fitting and logical-restoration paths, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a message of Persian or Arabic digits alone is now laid out back to front in the i18n layout code. It matches the changeset, which updates has_rtl to count those digit…
Description check Passed The description follows the template's main sections. The Summary explains the cause, the changes, and the scope. The Testing section lists the new tests and the commands run, and it states which chec…
Linked Issues check Passed [#3404] Requires that a message of only Persian or Arabic digits (for example ۱۲۳) be laid out in the same reading order as when a right-to-left letter stands beside it. At head, has_rtl in `crates/…
Out of Scope Changes check Passed All changed hunks relate to #3404. display_marks.rs changes the has_rtl predicate, adds the shared rtl_strong helper, adds has_rtl_letter for the fit_line cut, and updates a doc comment. `rt…
Full details: Title check

Explanation

The title names the main change: a message of Persian or Arabic digits alone is now laid out back to front in the i18n layout code. It matches the changeset, which updates has_rtl to count those digits, adds has_rtl_letter, and adds tests. The title follows the conventional commit format and references issue #3404. At 84 characters, it is slightly long but still clear.

Full details: Description check

Explanation

The description follows the template's main sections. The Summary explains the cause, the changes, and the scope. The Testing section lists the new tests and the commands run, and it states which checks were not run. The UI evidence section explains why no screenshot was taken, even though the template requires screenshots for visible UI changes. The change affects rendered text, so the reviewer may want a before-and-after screenshot. The Related issue section links #3404. The main gap is the UI evidence requirement. The author gave a reason but did not attach the required screenshots. The template also says to keep the 'No visible UI change.' line when there is no visible UI change, and the author replaced that line with an explanation. This is a partial gap, not a missing section, so the check passes.

Full details: Linked Issues check

Explanation

[#3404] Requires that a message of only Persian or Arabic digits (for example ۱۲۳) be laid out in the same reading order as when a right-to-left letter stands beside it. At head, has_rtl in crates/data/src/display_marks.rs now returns true for characters where rtl_strong matches: right-to-left script letters, U+0660–U+0669 and U+06F0–U+06F9. visual therefore rewrites digit-only text to ۳۲۱ for ۱۲۳. strong uses the same rtl_strong predicate, so visual_line and the checks agree. fit (crates/ui-egui/src/i18n/rtl.rs) and paragraph inherit the has_rtl change. The new test a_message_of_digits_alone_is_put_in_display_form asserts these outputs, and boundary_tests.rs adds a logical round-trip check. The fit_line change uses has_rtl_letter, which keeps the earlier letter-only meaning, so digits stay on a Latin-led row as the issue expects. Single digits, ASCII digits and left-to-right-led lines are unchanged in the asserted cases. I did not run the tests; the verdict rests on reading the diff and test assertions.

Full details: Out of Scope Changes check

Explanation

All changed hunks relate to #3404. display_marks.rs changes the has_rtl predicate, adds the shared rtl_strong helper, adds has_rtl_letter for the fit_line cut, and updates a doc comment. rtl.rs re-exports has_rtl_letter, switches the fit_line check to it, and adds tests. boundary_tests.rs adds a test only. The added tests cover the digit behavior that the issue describes. No unrelated code, interface, or command change appears in the diff. The PR description says no command or interface text changes, and the diff agrees.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the digits in a row,
Persian and Arabic now know where to go.
Letters guide the line break’s place,
Digits stay beside their Latin trace.
Back and forth, the marks align,
Then the rabbit hops along the line.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 073a81b3-9763-40da-9026-f4745c70453e
Commits

Reviewing files that changed from the base of the PR and between cc06db4 and a470085.

Files selected for processing: 3

  • crates/data/src/display_marks.rs
  • crates/ui-egui/src/i18n/boundary_tests.rs
  • crates/ui-egui/src/i18n/rtl.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Commit a470085 from a fork built, but isn't published until a maintainer adds the preview label (once per commit).

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A message of Persian or Arabic digits alone is painted backwards

1 participant