Support for different writing directions (left-to-right, right-to-left) is an important aspect for multilingual software. Since MediaWiki 1.18 , the support has been considerably improved.
This page gives some relevant information, and guidelines for developers and wiki administrators if you want to make a feature or extension compatible with the right-to-left interface and different directionality in general.
Some general tips for users, before getting to details for developers:
<div lang="en" dir="ltr" class="mw-content-ltr">
in the beginning and </div>
in the end.<span>
tag with appropriate lang and dir attributes. (Many wikis have a template for this, such as {{lang}}).You can report bugs in RTL handling in Phabricator in any MediaWiki-related project using the RTL tag.
Thanks to ResourceLoader including CSSJanus, CSS is automatically flipped to right-to-left when the user language is RTL. This is default since 1.18 (in previous versions it was dependent on the wiki content language). There is relatively little CSS that must depend on the content language.
Main article: Manual:Language
<div dir="..." lang="...">
tag.
div
tag.$diff->setTextLanguage( 'code' );
where $diff is a DifferenceEngine object.You should use HTML:
Xml::rawElement( 'div', array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() );
but sometimes that is difficult in dynamically generated elements and you can fall back on CSS:
.class { direction: ltr; }MediaWiki version:
≥ 1.18
You can use mw-content-ltr
and mw-content-rtl
classes to make use of edit section links and ul/ol elements based on that direction.
Xml::rawElement( 'div', array( 'class' => 'mw-content-' . $wgLang->getDir(), 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir(), 'Text' );
This is of course used for the page content of articles.
div
with lang
and dir
attributes according to the user language.Adding UI stuff within these classes should not be done. For example, the category links and FlaggedRevs review form are inside #bodyContent but outside .mw-content-ltr/rtl.
See also IDs and classes.
The body tag has an ltr
or rtl
class by default, which follows the user language. You shouldn't use that, because CSS is automatically flipped based on the user language. The body tag also features a new (1.18) sitedir-ltr
and sitedir-rtl
class which follows $wgContLang->getDir()
. If there is need for it, a "userlang-ltr/rtl" and/or "pagelang-ltr/rtl" could be added as well.
You can use $wgLang->alignStart()
, $wgContLang->alignStart()
, $wgLang->alignEnd()
, $wgContLang->alignEnd()
which gives the appropriate 'right' or 'left' values.
You can use CSS float
or text-align
of which the value (left/right) is flipped for RTL interface languages.
Special:AllMessages is a special page, which means it follows the user language direction. However, the actual messages should follow the direction of the selected language.
The cells in the table containing the content of the messages, have a lang
& dir
attribute.
The Translate extension, making use of the PageContentLanguage hook, sets the right language (and consequently direction) for translated pages, see e.g. meta:Wikimedia_maintenance_notice/ar which benefits from the mw-content-rtl class on an LTR wiki.
MediaWiki:Common.css pages and relatives are also flipped. This means that you have to add @noflip where needed.
See T33923: site CSS should not be flipped by default.
contlang
instead of pagelang
, otherwise special page returns userlang
[[File:Blabla.jpg|left]]
) should be aligned right in RTL wikis (minor issue)RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4