http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90742
Revision: 90742
Author: robin
Date: 2011-06-24 22:10:39 +0000 (Fri, 24 Jun 2011)
Log Message:
-----------
Directionality and language improvements as part of bug 6100 (under
$wgBetterDirectionality):
* Make TOC numberings be in the page content language instead of wiki content
language.
* Update getPageLanguage() and add a hook (for bug 9360/28970).
* Show redirects (when viewing a page with &redirect=no) in the user language
direction (not essential but nicer imo).
Modified Paths:
--------------
trunk/phase3/includes/Article.php
trunk/phase3/includes/Title.php
trunk/phase3/includes/parser/Parser.php
Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php 2011-06-24 22:08:11 UTC (rev 90741)
+++ trunk/phase3/includes/Article.php 2011-06-24 22:10:39 UTC (rev 90742)
@@ -1624,13 +1624,13 @@
* @return string containing HMTL with redirect link
*/
public function viewRedirect( $target, $appendSubtitle = true,
$forceKnown = false ) {
- global $wgOut, $wgContLang, $wgStylePath;
+ global $wgOut, $wgStylePath;
if ( !is_array( $target ) ) {
$target = array( $target );
}
- $imageDir = $wgContLang->getDir();
+ $imageDir = wfUILang()->getDir();
if ( $appendSubtitle ) {
$wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' )
);
@@ -1646,7 +1646,7 @@
}
$nextRedirect = $wgStylePath . '/common/images/nextredirect' .
$imageDir . '.png';
- $alt = $wgContLang->isRTL() ? '←' : '→';
+ $alt = wfUILang()->isRTL() ? '←' : '→';
// Automatically append redirect=no to each link, since most of
them are redirect pages themselves.
foreach ( $target as $rt ) {
$link .= Html::element( 'img', array( 'src' =>
$nextRedirect, 'alt' => $alt ) );
Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php 2011-06-24 22:08:11 UTC (rev 90741)
+++ trunk/phase3/includes/Title.php 2011-06-24 22:10:39 UTC (rev 90742)
@@ -4223,23 +4223,34 @@
}
/**
- * Get the language this page is written in
- * Defaults to $wgContLang
+ * Get the language in which the content of this page is written.
+ * Defaults to $wgContLang, but in certain cases it can be e.g.
+ * $wgLang (such as special pages, which are in the user language).
*
* @return object Language
*/
public function getPageLanguage() {
- global $wgContLang;
- $pageLang = $wgContLang;
- if ( $this->isCssOrJsPage() ) {
+ global $wgLang;
+ if ( $this->getNamespace() == NS_SPECIAL ) {
+ // special pages are in the user language
+ return $wgLang;
+ } elseif ( $this->isRedirect() ) {
+ // the arrow on a redirect page is aligned according to
the user language
+ return $wgLang;
+ } elseif ( $this->isCssOrJsPage() ) {
// css/js should always be LTR and is, in fact, English
- $pageLang = wfGetLangObj( 'en' );
+ return wfGetLangObj( 'en' );
} elseif ( $this->getNamespace() == NS_MEDIAWIKI ) {
// Parse mediawiki messages with correct target language
list( /* $unused */, $lang ) =
MessageCache::singleton()->figureMessage( $this->getText() );
- $pageLang = wfGetLangObj( $lang );
+ return wfGetLangObj( $lang );
}
- return $pageLang;
+ global $wgContLang;
+ // If nothing special, it should be in the wiki content language
+ $pageLang = $wgContLang;
+ // Hook at the end because we don't want to override the above
stuff
+ wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang,
$wgLang ) );
+ return wfGetLangObj( $pageLang );
}
}
Modified: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php 2011-06-24 22:08:11 UTC (rev
90741)
+++ trunk/phase3/includes/parser/Parser.php 2011-06-24 22:10:39 UTC (rev
90742)
@@ -4012,7 +4012,10 @@
if ( $dot ) {
$numbering .= '.';
}
- $numbering .= $wgContLang->formatNum(
$sublevelCount[$i] );
+ global $wgBetterDirectionality;
+ $pagelang =
$this->mTitle->getPageLanguage();
+ $toclang = ( $wgBetterDirectionality ?
$pagelang : $wgContLang );
+ $numbering .= $toclang->formatNum(
$sublevelCount[$i] );
$dot = 1;
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs