From a339803748d975efb07c935d43009da1034bb44c Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Fri, 17 Jun 2011 11:49:37 +0000 Subject: [PATCH] Improve lang and dir of content div (when $wgBetterDirectionality is enabled): * Do not set lang and dir for special pages (those are in the user language) * Set lang and dir of content of pages in MediaWiki namespace based on the current page instead of site language, e.g. MediaWiki:Message/ar is lang="ar" and dir="rtl" --- includes/SkinTemplate.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 3f90a2eaf4..ad309aa7e0 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -455,8 +455,19 @@ class SkinTemplate extends Skin { $tpl->set( 'printfooter', $this->printSource() ); global $wgBetterDirectionality; - if ( $wgBetterDirectionality ) { - $realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() ); + if ( $wgBetterDirectionality && $this->getTitle()->getNamespace() != NS_SPECIAL ) { + if( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) { + // If the page is in the MediaWiki NS, the lang and dir attribute should depend on that, + // i.e. MediaWiki:Message/ar -> lang=ar, dir=rtl. This assumes every message is translated, + // but it's anyway better than assuming it is always in the content lang + $nsMWTitle = $wgContLang->lcfirst( $this->getTitle()->getText() ); + list( $nsMWName, $nsMWLang ) = MessageCache::singleton()->figureMessage( $nsMWTitle ); + $nsMWDir = Language::factory( $nsMWLang )->getDir(); + $realBodyAttribs = array( 'lang' => $nsMWLang, 'dir' => $nsMWDir ); + } else { + // Body text is in the site content language (see also bug 6100 and 28970) + $realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() ); + } $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); } $tpl->setRef( 'bodytext', $out->mBodytext ); -- 2.20.1