Skip to content

feat: Add a leading RLM to RTL translations that start with LTR text - #4578

Draft
Goudarz wants to merge 2 commits into
mozilla:mainfrom
Goudarz:fix-3236-rtl-leading-mark
Draft

Goudarz wants to merge 2 commits into
mozilla:mainfrom
Goudarz:fix-3236-rtl-leading-mark

Conversation

@Goudarz

@Goudarz Goudarz commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #3236

Adds the fix suggested in the issue. In RTL locales, where the beginning strong character in a translation is LTR (such as placeholders and brand names), and there is some RTL text in that translation, an RLM will be added to the beginning of all patterns on save to display it RTL. Bidi isolation in Firefox is off (intl.l10n.enable-bidi-marks, bug 1439018), so a leading placeable does set the paragraph direction.

  • The RLM is invisible in the editor, added when saving the file, which allows editing and detecting unsaved changes as before. It is also added on save from the FTL source view.
  • Leading LRM opts out. Leading RLM or ALM is not duplicated.
  • "RLM" badge in the editor menu becomes visible if this mark is going to be added.
  • Unchanged translations are not saved anymore, and thus existing translations will get the RLM only when someone edits them, in accordance with the W3C string-meta recommendation not to add it to existing strings.
  • Translate Toolkit considered the RLM a starting punctuation, so we skip both leading and trailing directional marks in the checks for them.

End-to-end tested in Firefox/Edge with plain and Fluent strings (saving, reloading, opt-out, source view).

The open question is whether it makes sense to add the ability to insert the LRM as a response to clicking the badge, as typing an LRM as an opt-out in a particular case depends on the OS and the keyboard layout (for example, Ctrl+Shift+3 on Windows Persian, AltGr+9 on Linux, nothing standard on macOS).

Screenshots

before-after

@mathjazz
mathjazz requested a review from eemeli October 7, 2026 21:03
@eemeli

eemeli commented Oct 8, 2026

Copy link
Copy Markdown
Member

I'm not really sure that the bar below the editor is the right place for the RLM indicator, as it's not at all obvious which point of the string it's inserted into. I agree with @ItielMaN that the translator should be made aware of what's happening, even if the rendering in Pontoon is correct.

It might make sense to explicitly show the RLM inline in the editor, which effectively means that we ought to tackle #4332 before fixing this.

@Goudarz

Goudarz commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks that makes sense: the badge doesn't show where the mark goes. I'll convert this to a draft for now.

Is anyone working on #4332? If not I'd be happy to pick it up following @ayshushus design. Once point marks like RLM/LRM/ALM can be shown inline this PR could show the RLM where its added of the badge.

Alternatively if it helps to land this I could replace the badge with an inline marker, at the start of each pattern that gets the RLM styled like the point marks proposed in #4332. Which would you prefer?

@Goudarz
Goudarz marked this pull request as draft October 8, 2026 13:20
@eemeli

eemeli commented Oct 8, 2026

Copy link
Copy Markdown
Member

Working on #4332 sounds like an excellent idea; that's not actively worked on by anyone atm. I think you may need to comment on that issue before we can assign it to you?

Let's not land this before that, and figure out in general how to represent invisible characters, rather than RLM specifically first.

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.

RTL translations that start with LTR characters may be mis-rendered

2 participants