Last modified: 2014-09-23 22:33:16 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T15673, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 13673 - Supporting directionality for references
Supporting directionality for references
Product: MediaWiki extensions
Classification: Unclassified
Cite (Other open bugs)
All All
: Low enhancement with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: i18n
Depends on:
Blocks: rtl
  Show dependency treegraph
Reported: 2008-04-09 18:49 UTC by Huji
Modified: 2014-09-23 22:33 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Huji 2008-04-09 18:49:47 UTC
I started to work on this a while ago, but didn't have time to finish it. As this is a needed and useful feature, I'm asking here to seek attention from other developers.

Cite should support directionality for references. It can be accomplished by adding a new param to the <ref> tag like this:

<ref dir="rtl"> ...

which would make the output LI elemnt to render like this:

<li dir="rtl"> ...

In order to make sure the margins and paddings of the LI elements are rendered correctly, I suggest using a CSS class for it like <li class="rtl-reference">   .rtl-reference{ direction:rtl}

Also, "ltr" should be supported too (to be used on rtl wikis). The default direction will be that of the wiki, of course.
Comment 1 sharon.dagan 2008-10-07 23:01:26 UTC
Bidirectional references are already supported:

Hello World<ref group="hebrew">HEBREW TEXT HERE (WHICH IS RTL)</ref>
How are you doing<ref>Book of kings, p.123</ref>


==Hebrew Refs==
<div dir="rtl">
<references group="hebrew"/>
Comment 2 Huji 2008-10-08 06:50:44 UTC
Thanks Sharon for pointing it out. However, that way the order of references changes for the sake of grouping. What I'm suggesting here is that references should all be shown with one <references/> tag in the same order as if they were all in LTR, but RTL ones are handled correctly (or vice-versa if the content language is RTL itself). I'm reopening the bug since what you suggested is a workaround rather than a solution.
Comment 3 sharon.dagan 2008-10-08 08:23:22 UTC
Do you think it would be visually appealing to mix LTR and RTL references in the same block? 

Comment 4 Huji 2008-11-02 19:18:06 UTC
(In reply to comment #3)
> Do you think it would be visually appealing to mix LTR and RTL references in
> the same block? 
I totally understand what you mean. However, the fact that this has been required in a large scale RTL wiki like Persian Wikipedia, may be provided as a proof for its being appealing :) Anyways, this is possible and (I believe) easy to incorporate LTR and RTL refs, and I don't have a good reason not to do so (although I don't have a good reason pro either).
Comment 5 Huji 2010-10-26 19:15:13 UTC
For the record, using "group" attribute is not a solution anymore, because the name of the group is shown in the citation number in the text.
Comment 6 Eran Roz 2012-05-08 19:29:08 UTC
I'm not sure what is the best solution here: Mixed RTL and LTR lists doesn't look well, but English reference shown as RTL looks bad too.

In Hebrew Wikipedia I created a hack for setting the directionality using some CSS and overriding the reference name:
in common.css I added the following CSS
li[id|="cite_note-hebrewRTL"] {
li[id|="cite_note-LTR"] {

and users can exlicity set the direction by giving name to ref with the correct prefix:
<ref name="LTR-source">LTR reference</ref>
<ref name="hebrewRTL-source">RTL reference (which used when most of the references are LTR and the <references/> it wrapped by dir="ltr")</ref>

An example to it:

However, this hack uses CSS rules that are not supported by old browsers, and it isn't user friendly. 

Another [wrong] solution is to use the new dir="auto": the message MediaWiki:Cite_references_link_one could just declare dir="auto" for the li - this currently works only in Chrome. it doesn't requires the user to declare the direction of each reference, but sometimes users may want to explicitly define the direction (example: <ref>Google הוא מנוע חיפוש</ref>).
Comment 7 Huji 2012-05-09 14:33:43 UTC
The CSS based solution you have provided here, is exactly what I requested in the first place. It was questioned if it is appealing or not. Now that two large RTL wikis want this (FaWP and HeWP) and one of them has implemented this (HeWP), I think it is obvious that this is a necessity that should be addressed.

The problem with your approach is not only about lack of support for older browsers. It also makes it impossible to use the "name" attribute for its actual intended purpose. The solution I proposed in the beginning, allows for selectively marking reference as RTL, such that:

<ref dir="rtl">blah</ref>

generates something like:

<li class="citation-rtl">....

and we can define a class for that in the CSS.
Comment 8 Eran Roz 2012-05-15 20:17:19 UTC
I added support for it in:
Comment 9 Amir E. Aharoni 2012-05-15 20:53:37 UTC
Thanks for the patch, but the the look of the resulting comment is quite weird. In the following case, the wiki is LTR, the first comment is LTR and the second is RTL:

1. ↑ First English comment.
2.                                .SECOND PERSIAN COMMENT ↑

It would be less weird this way:

1. ↑ First English comment.

The layout at the bottom of is relatively better:

1. ↑ First English comment.
                                .SECOND HEBREW COMMENT ↑ .2
3. ↑ Third English comment.
4. ↑ Fourth English comment.
                                 .FIFTH HEBREW COMMENT ↑ .5

... But still, putting the comment numbers on different sides of the page is very weird.

In printed Hebrew books the numbers are always on the right and the alignment is always to the right, even if the comment is in an LTR language.

In an RTL wiki I would align comments to the left only if all of them are LTR.
Comment 10 Huji 2012-05-15 22:37:26 UTC
If all citations are in the same direction (regardless of whether it is the same as the directionality of the wiki content), there is no need to use this new feature. Instead, the whole section can be wrapped in a div, with its directionality set to the desired direction.

The use of this feature is only when some (and not all) of the citations are in the direction opposite to the directionality of the content. I am in support of allowing the direction to be set for the LI element itself. Unlike Amir, I think the layout is not weird. In Persian text, this form of numbering is quite frequent for footnotes and citations.

Last but not least, wrapping the inside of ref tag in a DIV is not a solution. We actually can do that simply by using <ref><div class="whatever">...</div></ref> so there is no need to implement that DIV in the extension code. The first output in comment #9 can be achieved that way, with no change in the extension.

Therefore, I propose the patch to be modified again, in such a way that the CLASS attribute would be added to the LI element itself, not to a DIV element inside of it.
Comment 11 Huji 2012-05-24 00:25:27 UTC
I modified the latter patch to comply with what is requested in this bug, in
Comment 12 Eran Roz 2012-05-24 03:55:23 UTC
I thought it is a bit weird that the numbers are on different sides, and that is the reason for the div within the ref. Regarding the comment 10# it is not the same as adding div within the ref (<ref><div dir="ltr">...</div></ref>), as the whole comment (including the backlink) is in a the "correct" direction (while keeping the numbers in the same side), and without a line break.

However after the discussion here I changed my mind and the other options are fine (and better than the current situation). I did a small survey in the Hebrew community Wikipedia:
and 4 ppl thought the more correct output is as Huji said (to assign dir to the li), while 4 ppl thought the correct output is as Amir said (directionality within the reference-text+ unicode-bidi: embed) - so it is still not clear what is the correct output :) Maybe we should ask the main RTL communities (fa-wikipedia, ar-wikipedin) what they prefer. If we don't ask them, I think adding the class to the li is fine too.
Comment 13 Dereckson 2012-06-18 00:04:26 UTC
Code review: Gerrit change #7738.

Assigned to patch submitter.
Comment 14 Sumana Harihareswara 2013-02-21 23:11:11 UTC
Assigning to submitter of most recent amended patchset, Antoine Musso.
Comment 15 Andre Klapper 2013-07-25 08:20:10 UTC
Patch in Gerrit received a -1, needs rework.
Comment 16 Gerrit Notification Bot 2014-04-08 17:59:26 UTC
Change 7738 had a related patch set uploaded by Krinkle:
Support directionality for reference

Note You need to log in before you can comment on or make changes to this bug.