* (bug 13274) Change links for messages to ucfirst
* (bug 13273) "Categories:" message at the bottom of the page shouldn't have
hardcoded colon, use new 'colon-separator' message instead
+* Parse MediaWiki message translations with a correct language setting on preview
=== API changes in 1.13 ===
* @todo document
*/
function getPreviewText() {
- global $wgOut, $wgUser, $wgTitle, $wgParser;
+ global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang;
$fname = 'EditPage::getPreviewText';
wfProfileIn( $fname );
$toparse="== {$this->summary} ==\n\n".$toparse;
}
- if ( $this->mMetaData != "" ) $toparse .= "\n" . $this->mMetaData ;
+ if ( $this->mMetaData != "" ) $toparse .= "\n" . $this->mMetaData;
+
+ // Parse mediawiki messages with correct target language
+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
+ $pos = strrpos( $this->mTitle->getText(), '/' );
+ if ( $pos !== false ) {
+ $code = substr( $this->mTitle->getText(), $pos+1 );
+ switch ($code) {
+ case $wgLang->getCode():
+ $obj = $wgLang; break;
+ case $wgContLang->getCode():
+ $obj = $wgContLang; break;
+ default:
+ $obj = Language::factory( $code );
+ }
+ $parserOptions->setTargetLanguage( $obj );
+ }
+ }
+
+
$parserOptions->setTidy(true);
$parserOptions->enableLimitReport();
$parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ) ."\n\n",
function getFunctionLang() {
global $wgLang, $wgContLang;
- return $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang;
+
+ $target = $this->mOptions->getTargetLanguage();
+ if ( $target !== null ) {
+ return $target;
+ } else {
+ return $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang;
+ }
}
/**
var $mAllowSpecialInclusion; # Allow inclusion of special pages
var $mTidy; # Ask for tidy cleanup
var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR
+ var $mTargetLanguage; # Overrides above setting with arbitrary language
var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
function getTidy() { return $this->mTidy; }
function getInterfaceMessage() { return $this->mInterfaceMessage; }
+ function getTargetLanguage() { return $this->mTargetLanguage; }
function getMaxIncludeSize() { return $this->mMaxIncludeSize; }
function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; }
function getMaxTemplateDepth() { return $this->mMaxTemplateDepth; }
function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); }
function setSkin( $x ) { $this->mSkin = $x; }
function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); }
+ function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage, $x); }
function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); }
function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount, $x ); }
function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth, $x ); }
$this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
$this->mTidy = false;
$this->mInterfaceMessage = false;
+ $this->mTargetLanguage = null; // default depends on InterfaceMessage setting
$this->mMaxIncludeSize = $wgMaxArticleSize * 1024;
$this->mMaxPPNodeCount = $wgMaxPPNodeCount;
$this->mMaxTemplateDepth = $wgMaxTemplateDepth;