Skip to content

fix: isolate placeables as LTR in RTL translations - #4572

Open
Goudarz wants to merge 3 commits into
mozilla:mainfrom
Goudarz:fix-4054-rtl-placeable-isolation
Open

Goudarz wants to merge 3 commits into
mozilla:mainfrom
Goudarz:fix-4054-rtl-placeable-isolation

Conversation

@Goudarz

@Goudarz Goudarz commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4054

In RTL locales the BiDi algorithm was reordering tags and placeholders such as </strong>, causing them to appear as strong> … /< in both the translation list and the string list; however, the editor was not affected since CodeMirror had already isolated them as LTR.

The addition of dir="ltr" to the code-like placeables in Highlight also ensures that they are isolated and thus displayed in the same way as they do in the editor. Whitespace, newlines and punctuation remain unchanged.

Screenshots

Before
Persian (fa):
Screenshot 2026-10-06 at 02-42-47 Pontoon
Urdu (ur):
Screenshot 2026-10-06 at 02-42-10 Pontoon

After
Persian (fa):
Screenshot 2026-10-06 at 02-43-22 Persian (fa) · RTL Test
Urdu (ur):
Screenshot 2026-10-06 at 02-25-19 Urdu (ur) · RTL Test

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

Left a comment inline.

mark: (
<Localized id={l10nId} attrs={{ title: true }} key={++keyCounter}>
<mark className='placeable' data-match={text}>
<mark className='placeable' data-match={text} dir='ltr'>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the number is -1? In RTL text that will put the minus on the right in plain text but on the left with dir="ltr", right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks that is a question! Without isolation the minus sign ends up on the right. For Persian the expected form is the opposite way around. The FarsiWeb locale requirements that CLDRs Persian data is based on (linked from https://cldr.unicode.org/translation/language-specific/persian p. 12) Say that the minus sign (U+2212) should go on the side of the digits for example «−۱۲۳٫۴». CLDR does the same for fa, ur he and ar‑Latn by putting an LRM before the minus sign.

Therefore I kept signed numbers isolated as left‑to‑right. Expanded the number pattern to include Persian digits, U+2212 and Persian separators. Unsigned numbers are no longer isolated; ranges like 1-2 remain unchanged and Arabic‑Indic digits are left untouched because CLDR places the minus sign on the side for Arabic‑Indic digits. The value -1 was also being treated as a CLI option. That issue is now fixed. I added tests for all of these changes.

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.

Display issues for strings with consecutive HTML tags and placeholders in RTL languages

2 participants