Page MenuHomePhabricator

Timestamp tooltip text order is reversed ("years ago 8") on RTL wikis with LTR interface language
Open, Needs TriagePublicBUG REPORT

Description

When hovering over a timestamp generated by DiscussionTools on an RTL wiki (tested on arwiki and arzwiki), the tooltip text containing English characters and numbers is displayed in the wrong visual order due to bidirectional text rendering issues. Instead of showing "8 years ago", the tooltip visually displays "years ago 8".

Steps to Reproduce:

image.png (1,009×475 px, 58 KB)

<a href="https://ar.wikipedia.org/wiki/%D9%86%D9%82%D8%A7%D8%B4_%D8%A7%D9%84%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:Vermont#c-Bachounda-2018-03-24T17:08:00.000Z" class="ext-discussiontools-init-timestamplink" title="8 years ago" data-event-name="discussiontools.permalink-copied">17:08، 24 مارس 2018 (ت&nbsp;ع&nbsp;م)</a>

Expected Result:
The tooltip should correctly read "8 years ago".

I guess Wrapping the string with LRI (Left-to-Right Isolate, U+2066) at the beginning and PDI (Pop Directional Isolate, U+2069) at the end would force the browser to render the tooltip correctly as LTR.

Event Timeline

Restricted Application added subscribers: hubaishan, Aklapper. · View Herald Transcript

MediaWiki has a helper function with a similar purpose, Language::embedBidi(), but a) it uses the older "embedding" control characters rather than the "isolate" ones b) it is marked as deprecated in favor of using HTML markup. We generally prefer using HTML attributes rather than Unicode directional formatting characters, I believe it's mostly because they behave better when copy-pasting – it's easy to copy-paste text with just one control char out of a pair like LRI+PDI without realizing it, and unknowingly mess up the text direction somewhere else on the page. The copy-pasting concern doesn't really apply to a title attribute, since those are difficult to copy-paste anyway.

In this case, in addition to not being marked up with the correct directionality, the tooltip text is also not marked up with the correct language. That may be worth fixing as well, and would have to be done with HTML markup; however, it's a bit tricky to do, because it's an attribute in English of a tag whose content is in Arabic. I believe something like this is technically correct, but I'm not sure whether it couldn't cause some weird artifacts at the transition points from RTL to LTR and back to RTL, without any actual LTR text.

<a href="https://ar.wikipedia.org/wiki/%D9%86%D9%82%D8%A7%D8%B4_%D8%A7%D9%84%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:Vermont#c-Bachounda-2018-03-24T17:08:00.000Z" class="ext-discussiontools-init-timestamplink" title="8 years ago" data-event-name="discussiontools.permalink-copied" lang="en" dir="ltr"><span lang="ar" dir="rtl">17:08، 24 مارس 2018 (ت&nbsp;ع&nbsp;م)</span></a>

So, to summarize my over-thinking this, your proposed solution is the simplest and probably the best one. Perhaps one day this could be changed so that the content of the tag will be localised as well (T240360).

matmarex renamed this task from Timestamp tooltip text order is reversed ("years ago 8") on RTL wikis to Timestamp tooltip text order is reversed ("years ago 8") on RTL wikis with LTR interface language.Jul 28 2026, 8:45 PM
matmarex updated the task description. (Show Details)