Index: trunk/phase3/includes/CategoryPage.php |
— | — | @@ -179,6 +179,12 @@ |
180 | 180 | $r = wfMsgExt( 'category-empty', array( 'parse' ) ); |
181 | 181 | } |
182 | 182 | |
| 183 | + global $wgBetterDirectionality, $wgLang; |
| 184 | + if( $wgBetterDirectionality ) { |
| 185 | + $langAttribs = array( 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ); |
| 186 | + $r = Html::rawElement( 'div', $langAttribs, $r ); |
| 187 | + } |
| 188 | + |
183 | 189 | wfProfileOut( __METHOD__ ); |
184 | 190 | return $wgContLang->convert( $r ); |
185 | 191 | } |
— | — | @@ -501,12 +507,21 @@ |
502 | 508 | */ |
503 | 509 | function formatList( $articles, $articles_start_char, $cutoff = 6 ) { |
504 | 510 | if ( count ( $articles ) > $cutoff ) { |
505 | | - return self::columnList( $articles, $articles_start_char ); |
| 511 | + $list = self::columnList( $articles, $articles_start_char ); |
506 | 512 | } elseif ( count( $articles ) > 0 ) { |
507 | 513 | // for short lists of articles in categories. |
508 | | - return self::shortList( $articles, $articles_start_char ); |
| 514 | + $list = self::shortList( $articles, $articles_start_char ); |
509 | 515 | } |
510 | | - return ''; |
| 516 | + global $wgBetterDirectionality; |
| 517 | + if( $wgBetterDirectionality ) { |
| 518 | + global $wgOut, $wgContLang; |
| 519 | + $getPageLang = $wgOut->parserOptions()->getTargetLanguage(); |
| 520 | + $pageLang = ( $getPageLang ? Language::factory( $getPageLang ) : $wgContLang ); |
| 521 | + $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
| 522 | + $list = Html::rawElement( 'div', $realBodyAttribs, $list ); |
| 523 | + } |
| 524 | + |
| 525 | + return $list; |
511 | 526 | } |
512 | 527 | |
513 | 528 | /** |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -66,7 +66,15 @@ |
67 | 67 | function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } |
68 | 68 | function getTidy() { return $this->mTidy; } |
69 | 69 | function getInterfaceMessage() { return $this->mInterfaceMessage; } |
70 | | - function getTargetLanguage() { return $this->mTargetLanguage; } |
| 70 | + function getTargetLanguage( $title = null ) { |
| 71 | + // Parse mediawiki messages with correct target language |
| 72 | + if ( $title && $title->getNamespace() == NS_MEDIAWIKI ) { |
| 73 | + list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() ); |
| 74 | + $obj = wfGetLangObj( $lang ); |
| 75 | + return $obj; |
| 76 | + } |
| 77 | + return $this->mTargetLanguage; |
| 78 | +} |
71 | 79 | function getMaxIncludeSize() { return $this->mMaxIncludeSize; } |
72 | 80 | function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; } |
73 | 81 | function getMaxPPExpandDepth() { return $this->mMaxPPExpandDepth; } |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -1815,6 +1815,14 @@ |
1816 | 1816 | 'style' => '' // avoid php notices when appending preferences (appending allows customAttribs['style'] to still work |
1817 | 1817 | ); |
1818 | 1818 | |
| 1819 | + global $wgBetterDirectionality, $wgContLang; |
| 1820 | + if( $wgBetterDirectionality ) { |
| 1821 | + $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle ); |
| 1822 | + $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
| 1823 | + $attribs['lang'] = $pageLang->getCode(); |
| 1824 | + $attribs['dir'] = $pageLang->getDir(); |
| 1825 | + } |
| 1826 | + |
1819 | 1827 | $wgOut->addHTML( Html::textarea( $name, $wikitext, $attribs ) ); |
1820 | 1828 | } |
1821 | 1829 | |
— | — | @@ -2058,13 +2066,6 @@ |
2059 | 2067 | |
2060 | 2068 | wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) ); |
2061 | 2069 | |
2062 | | - // Parse mediawiki messages with correct target language |
2063 | | - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
2064 | | - list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->mTitle->getText() ); |
2065 | | - $obj = wfGetLangObj( $lang ); |
2066 | | - $parserOptions->setTargetLanguage( $obj ); |
2067 | | - } |
2068 | | - |
2069 | 2070 | $parserOptions->setTidy( true ); |
2070 | 2071 | $parserOptions->enableLimitReport(); |
2071 | 2072 | $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ), |
— | — | @@ -2091,6 +2092,13 @@ |
2092 | 2093 | $wgOut->parse( $note ) . $conflict . "</div>\n"; |
2093 | 2094 | |
2094 | 2095 | wfProfileOut( __METHOD__ ); |
| 2096 | + global $wgBetterDirectionality, $wgContLang; |
| 2097 | + if( $wgBetterDirectionality ) { |
| 2098 | + $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle ); |
| 2099 | + $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
| 2100 | + $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
| 2101 | + $previewHTML = Html::rawElement( 'div', $realBodyAttribs, $previewHTML ); |
| 2102 | + } |
2095 | 2103 | return $previewhead . $previewHTML . $this->previewTextAfterContent; |
2096 | 2104 | } |
2097 | 2105 | |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -455,20 +455,17 @@ |
456 | 456 | $tpl->set( 'printfooter', $this->printSource() ); |
457 | 457 | |
458 | 458 | global $wgBetterDirectionality; |
459 | | - if ( $wgBetterDirectionality && $this->getTitle()->getNamespace() != NS_SPECIAL ) { |
460 | | - if( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) { |
461 | | - // If the page is in the MediaWiki NS, the lang and dir attribute should depend on that, |
462 | | - // i.e. MediaWiki:Message/ar -> lang=ar, dir=rtl. This assumes every message is translated, |
463 | | - // but it's anyway better than assuming it is always in the content lang |
464 | | - $nsMWTitle = $wgContLang->lcfirst( $this->getTitle()->getText() ); |
465 | | - list( $nsMWName, $nsMWLang ) = MessageCache::singleton()->figureMessage( $nsMWTitle ); |
466 | | - $nsMWDir = Language::factory( $nsMWLang )->getDir(); |
467 | | - $realBodyAttribs = array( 'lang' => $nsMWLang, 'dir' => $nsMWDir ); |
468 | | - } else { |
469 | | - // Body text is in the site content language (see also bug 6100 and 28970) |
470 | | - $realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() ); |
| 459 | + if ( $wgBetterDirectionality ) { |
| 460 | + // not for special pages AND only when viewing AND if the page exists |
| 461 | + // (or is in MW namespace, because that has default content) |
| 462 | + if( $this->getTitle()->getNamespace() != NS_SPECIAL && |
| 463 | + in_array( $action, array( 'view', 'render', 'print' ) ) && |
| 464 | + ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) { |
| 465 | + $getPageLang = $out->parserOptions()->getTargetLanguage( $this->getTitle() ); |
| 466 | + $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
| 467 | + $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
| 468 | + $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); |
471 | 469 | } |
472 | | - $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); |
473 | 470 | } |
474 | 471 | $tpl->setRef( 'bodytext', $out->mBodytext ); |
475 | 472 | |