* Use ParserOptions()->getTargetLanguage() for setting the page language/direction
* Set headings on categories in user language/direction
* Only set language/direction when viewing a page (or editing but only preview and textarea)
$r = wfMsgExt( 'category-empty', array( 'parse' ) );
}
+ global $wgBetterDirectionality, $wgLang;
+ if( $wgBetterDirectionality ) {
+ $langAttribs = array( 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() );
+ $r = Html::rawElement( 'div', $langAttribs, $r );
+ }
+
wfProfileOut( __METHOD__ );
return $wgContLang->convert( $r );
}
*/
function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
if ( count ( $articles ) > $cutoff ) {
- return self::columnList( $articles, $articles_start_char );
+ $list = self::columnList( $articles, $articles_start_char );
} elseif ( count( $articles ) > 0 ) {
// for short lists of articles in categories.
- return self::shortList( $articles, $articles_start_char );
+ $list = self::shortList( $articles, $articles_start_char );
}
- return '';
+ global $wgBetterDirectionality;
+ if( $wgBetterDirectionality ) {
+ global $wgOut, $wgContLang;
+ $getPageLang = $wgOut->parserOptions()->getTargetLanguage();
+ $pageLang = ( $getPageLang ? Language::factory( $getPageLang ) : $wgContLang );
+ $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
+ $list = Html::rawElement( 'div', $realBodyAttribs, $list );
+ }
+
+ return $list;
}
/**
'style' => '' // avoid php notices when appending preferences (appending allows customAttribs['style'] to still work
);
+ global $wgBetterDirectionality, $wgContLang;
+ if( $wgBetterDirectionality ) {
+ $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle );
+ $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
+ $attribs['lang'] = $pageLang->getCode();
+ $attribs['dir'] = $pageLang->getDir();
+ }
+
$wgOut->addHTML( Html::textarea( $name, $wikitext, $attribs ) );
}
wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
- // Parse mediawiki messages with correct target language
- if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->mTitle->getText() );
- $obj = wfGetLangObj( $lang );
- $parserOptions->setTargetLanguage( $obj );
- }
-
$parserOptions->setTidy( true );
$parserOptions->enableLimitReport();
$parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
$wgOut->parse( $note ) . $conflict . "</div>\n";
wfProfileOut( __METHOD__ );
+ global $wgBetterDirectionality, $wgContLang;
+ if( $wgBetterDirectionality ) {
+ $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle );
+ $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
+ $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
+ $previewHTML = Html::rawElement( 'div', $realBodyAttribs, $previewHTML );
+ }
return $previewhead . $previewHTML . $this->previewTextAfterContent;
}
$tpl->set( 'printfooter', $this->printSource() );
global $wgBetterDirectionality;
- 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() );
+ if ( $wgBetterDirectionality ) {
+ // not for special pages AND only when viewing AND if the page exists
+ // (or is in MW namespace, because that has default content)
+ if( $this->getTitle()->getNamespace() != NS_SPECIAL &&
+ in_array( $action, array( 'view', 'render', 'print' ) ) &&
+ ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) {
+ $getPageLang = $out->parserOptions()->getTargetLanguage( $this->getTitle() );
+ $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
+ $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
+ $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
}
- $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
}
$tpl->setRef( 'bodytext', $out->mBodytext );
function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
function getTidy() { return $this->mTidy; }
function getInterfaceMessage() { return $this->mInterfaceMessage; }
- function getTargetLanguage() { return $this->mTargetLanguage; }
+ function getTargetLanguage( $title = null ) {
+ // Parse mediawiki messages with correct target language
+ if ( $title && $title->getNamespace() == NS_MEDIAWIKI ) {
+ list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
+ $obj = wfGetLangObj( $lang );
+ return $obj;
+ }
+ return $this->mTargetLanguage;
+}
function getMaxIncludeSize() { return $this->mMaxIncludeSize; }
function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; }
function getMaxPPExpandDepth() { return $this->mMaxPPExpandDepth; }