Jump to content

Project:Better directionality and i18n development

From translatewiki.net
This page is outdated and needs updating.

Please see mw:Directionality support


This page lists bugs, for the technical implementation and other info, see http://robinpepermans.be/mw-dev/index.php?title=Project:RTL

  • Italic lines are issues that were already present before enabling wgBetterDirectionality / fixing bug 6100.
  • Note that this page may have issues striked through that are not yet fixed in SVN

Basic development guidelines

  • Input boxes should follow content direction. Path and URL input are usually LTR.
  • Skins (in order of approximate importance): vector, monobook, cologneblue, modern, classic, chick, nostalgia, simple

Issues in MediaWiki core

  • all input fields by default in content language
  • Dirmarks in Special:Contributions (mwr:91289)
  • Sitenotice should be in content dir (mwr:91300)
  • fix image left/right alignment on RTL wikis (inconsistent between skins!!) (mwr:91340)
  • CologneBlue/Standard: due to CSS flipping, preferences said quickbar was left, while it was right (similar to image issue) (mwr:91432)
  • External link icons
    • vector/monobook/modern/simple: icons always follow user direction -> minor bug, quite difficult to fix
    • chick/standard/cologneblue: don't use icons so no problem
  • firstHeading: I'd like to keep it at the side of userlang, but it mostly follows contentlang. Maybe add DirMarks? Or align it to content direction anyway?
  • dirmark for protect log (done partially, bugzilla:15897 needs to be fixed)

Fallback

If an LTR language is a the fallback for an RTL language, an untranslated message will appear as RTL and this is not great. It's not a problem for Hebrew, Arabic and Persian, because practically everything is translated, but other languages, such as Urdu, have many messages in English. For example, at Special:LanguageStats/ur, you'll have the following message

Translation statistics for اردو (recent translations).

It should appear like this:

Translation statistics for اردو (recent translations).

(The word in the middle "اردو" is the name of the language – "Urdu".)

Thanks. --Amir E. Aharoni 23:11, 22 July 2011 (UTC)

As far as I know, this is nearly impossible to fix in MediaWiki, unfortunately. First, I don't think there is an easy way to know whether the message is written in the fallback language. Secondly, it's not really feasible to add align each message according to the direction of the language. SPQRobin 15:14, 23 July 2011 (UTC)
Incorrect, the solution really exists and it is very reliable and simple to use: make sure that all transclusions of translatable submessages, for which you can't predict which direction it will have, are made inside HTML "bdi" tags that will completely isolate the submessage, independantly of the language in which it will finally appear (i.e. if the submessage was translated or not). So your last example should be written as
<span dir="ltr">Translation statistics for <bdi>اردو <!--x-->(بھارت)</bdi> (recent translations).</span>
<span dir="ltr">Translation statistics for <bdi>Urdu (India)</bdi> (recent translations).</span>
(the dummy "x" comment above is just to show that logical input order is used in Arabic, even when the source wikicode is edited or viewed in an LTR context like this page, it avoids the mirroring and move of parentheses and facilitates the editing, because the Latin "x" is an LTR letter that is used to restore the LTR context of the "Wikicode/HTML" language; MediaWiki will silently discard these HTML comments) which will render correctly as:
Translation statistics for اردو (بھارت) (recent translations).
Translation statistics for Urdu (India) (recent translations).
and in an RTL page it will also correctly render as:
Translation statistics for اردو (بھارت) (recent translations).
Translation statistics for Urdu (India) (recent translations).
Note that you do not even need the span to specify the direction of the content, if that content starts by some subtext in a strong direction. But you would need it in the following case:
<span dir="ltr"><bdi>اردو <!--x-->(بھارت)</bdi> is fully translated.</span>
<span dir="ltr"><bdi>Urdu (India)</bdi> is fully translated.</span>
which will render correctly as:
اردو (بھارت) is fully translated.
Urdu (India) is fully translated.
and in an RTL page it will also correctly render as:
اردو (بھارت) is fully translated.
Urdu (India) is fully translated.
This is the only case where you need to set the direction explicitly for the translation of the main message (even in the English message here!), according to the language of that translation and not the language of the page where it this message will be used, because the direction is not determined at start of the message and this complete English message will not render correctly as a fallback for any RTL language. You must use it with the dir="ltr/rtl" attribute (encapsulating that whole message just within a "bdi" tag will not change this, you may use "bdi" instead of span, but then you'll also need to add the dir="ltr/rtl" attribute to the leacing tag or to a container. Such encapsulation of fallback messages with bdi (preferably also with the dir="" and lang="" attributes for the actual language of the selected fallback) may be done in the code implementing the fallbacks, each time the fallback is used, but is not needed if the message is not a fallback but an actual translation.
But without this dir-span it you would get this incorrect order in an RTL page, because the English contents starts by a subtext in an unknown direction:
اردو (بھارت) is fully translated.
Urdu (India) is fully translated.
this is correct as a fallback to English for any LTR page, but compare to this incorrect placement when this message is used as a fallback in a RTL page:
اردو (بھارت) is fully translated.
Urdu (India) is fully translated.
Do NOT use the "Bidi control" characters (only added in Unicode for plain-text only document, from a transformed rich text document where all languages and directions are necessarily resolved locally): they never work reliably in HTML and especially on editable wikis with dynamic changes, because their effect is local or because they break the normal direction of the text after the transcluded submessage and it's then impossible to manage them correctly (those Bidi controls should even be banned from MediaWiki, except in "source" or "pre" tags whose text content is only static, but never translated except as the whole!).
This is not a feature of Mediawiki but a basic feature of HTML, fully supported by MediaWiki. Verdy p (talk) 16:57, 9 July 2019 (UTC)
Note that the editing trick of inserting dummy Latin "x" (or any other Latin/Greek/Cyrillic letter) facilitates the editing of bidirectional text in an LTR editor or context: this "x" trick may be needed in two kinds of places:
  • just before mirrored punctuations (possibly surrounded by "neutral" digits and other non-mirrored punctuations), or
  • before the final punctuation(s) of an RTL text (to make sure they are logically entered at end of text and not at start of it).
So start looking with your cursor where you can insert such dummmy "x" before these "bidi-neutral" punctuations (the first punctuation should then appear immediately to the left of the "x", otherwise this is not the correct place for the "x", and use the cursor keys to find the alternate position; when you've done that, surround these "x" in HTML comments; now your text will be editable in logical direction, with spans of changing directions correctly isolated, and cursor movement or text selection will be much easier!). This further allows easy placement of other HTML tags, template calls (without the bad effect of mirrored braces...), and so on; and it avoid ALL insertions of Bidi controls (that are then never needed) and allows a much easier tuning of directions.
This trick with the dummy "x" (when editing messages) works for all languages needing bidirectional transcriptions for their preferred right-to-left scripts: Hebrew, Yiddish, Arabic, Persian, Pashto, Urdu, Uyghur, Syriac, Samaritan, Maldivian... It is needed because of the existence of bidi-neutral punctuations or whitespaces (and notably the basic punctuation of US-ASCII, used in almost all scripts including RTL scripts), it is also needed for the decimal digits (whose glyphs may change in different scripts, but not their bidi-neutrality) it is not needed for the punctuations and symbols that have a strong direction (such as the Arabic comma), which are then never mirrored (arrows are never mirrored but they are bidi-neutral, so sometimes you need to use the "x" trick to make sure they are entered in the correct order, notably at start of text). You would not need this trick if all characters in Unicode had a strong LTR or RTL direction (this strong direction is true only for regular letters in each script, and for some letter-like symbols except notably the currency symbols used along with bidi-neutral digits and punctuations/separators, decimal digits are partly neutral in short spans containing only digits and punctuation in the middle even if they have a local-only LTR or RTL direction within these spans). Verdy p (talk) 17:43, 9 July 2019 (UTC)

Issues in extensions

Babel

  • Use a better way to decide whether a language is RTL (current depending on 'babel-directionality' msg)

CleanChanges

  • CleanChanges: history & recentchanges need DirMark

CodeReview (bugzilla:29658)

  • direction mark for revision paging links; paths and code diff should be LTR (mwr:91293)
  • summaries, comments, editing box should be content language
  • comments should be aligned right for RTL languages

Collection

FlaggedRevs

  • "unchecked" box on articles should follow content direction, not user direction

GlobalUsage

  • image alignment should follow user direction (mwr:90589)

Interwiki

  • Align titles on explanation table correctly (mwr:r90518)
  • Align URLs as LTR (mwr:r90518, mwr:r90519)
  • log displays incorrectly for url, solution: put url at the end i.e. prefix (trans) (local) (http://example.com), but that is not a logical order..

LiquidThreads

  • arrows are wrong (see e.g. Support) (mwr:91176)
  • PageContentLanguage: history, diff, thread view (mwr:91182, mwr:91338)
  • use .mw-content-ltr/rtl as well
  • LiquidThreads: use local languages digits on threads title. (۱۲۳۴۵۶۷۸۹۰ instead 1234567890 for Persian) (mwr:91338)
    • For reply in the URL? ("reply_(2)") (mwr:91528)
  • Use contlang instead of pagelang, otherwise special page returns userlang

Translate

  • In translation page: alignment of language names and Google/Microsoft etc.
  • In "Review all translate messages in": the direction of the source and the target language must match the right direction of each language. (mwr:91171)
  • If a message had only a minor change (for example, whitespace), it is not marked as FUZZY, but when it is translated, a diff is shown above the translation box. It's directionality must match the directionality of the source language and currently it seems to match the directionality of the target language. See the example. --Amir E. Aharoni 17:02, 16 July 2011 (UTC) (mwr:92956)
  • Translated pages (through the "translatable pages" feature) + other namespaces used for translation, should match the directionality of the language (93985)

UploadWizard (bugzilla:24692)

  • make RTL versions of the navigation arrows at the top of the page (mwr:91525)

WebFonts

Wikidata (OmegaWiki)

  • Expression and DefinedMeaning pages should follow user direction
    Please contact kipcool (committer) before making changes. He's the current maintainer of Wikidata.

WikiLove

  • kittens aligned left ([[File:Blabla.jpg|left]]) should be aligned right in RTL wikis (minor issue)
  • Background images of options buttons don't display properly (minor issue) (mwr:r93955)

Related