* @private
*/
function getContent( $def_text = '' ) {
- global $wgOut, $wgRequest, $wgParser, $wgMessageCache;
+ global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache;
wfProfileIn( __METHOD__ );
# Get variables from query string :P
// For other non-existent articles, use preload text if any.
if ( !$this->mTitle->exists() ) {
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- $wgMessageCache->loadAllMessages();
# If this is a system message, get the default text.
- $text = wfMsgWeirdKey( $this->mTitle->getText() ) ;
+ list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
+ $wgMessageCache->loadAllMessages( $lang );
+ $text = wfMsgGetKey( $message, false, $lang, false );
+ if( wfEmptyMsg( $message, $text ) )
+ $text = '';
} else {
# If requested, preload some text.
$text = $this->getPreloadedText( $preload );
*/
function initialiseForm() {
$this->edittime = $this->mArticle->getTimestamp();
- $this->textbox1 = $this->getContent(false);
- if ( $this->textbox1 === false) return false;
-
- if ( !$this->mArticle->exists() && $this->mTitle->getNamespace() == NS_MEDIAWIKI )
- $this->textbox1 = wfMsgWeirdKey( $this->mTitle->getText() );
+ $this->textbox1 = $this->getContent( false );
+ if ( $this->textbox1 === false ) return false;
wfProxyCheck();
return true;
}
var $mKeys, $mParserOptions, $mParser;
var $mExtensionMessages = array();
var $mInitialised = false;
- var $mAllMessagesLoaded; // Extension messages
+ var $mAllMessagesLoaded = array(); // Extension messages
// Variable for tracking which variables are loaded
var $mLoadedLanguages = array();
}
}
- function loadAllMessages() {
+ function loadAllMessages( $lang = false ) {
global $wgExtensionMessagesFiles;
- if ( $this->mAllMessagesLoaded ) {
+ $key = $lang === false ? '*' : $lang;
+ if ( isset( $this->mAllMessagesLoaded[$key] ) ) {
return;
}
- $this->mAllMessagesLoaded = true;
+ $this->mAllMessagesLoaded[$key] = true;
# Some extensions will load their messages when you load their class file
wfLoadAllExtensions();
wfRunHooks( 'LoadAllMessages' );
# Some register their messages in $wgExtensionMessagesFiles
foreach ( $wgExtensionMessagesFiles as $name => $file ) {
- wfLoadExtensionMessages( $name );
+ wfLoadExtensionMessages( $name, $lang );
}
# Still others will respond to neither, they are EVIL. We sometimes need to know!
}
public function figureMessage( $key ) {
global $wgContLanguageCode;
- $pieces = explode('/', $key, 2);
+ $pieces = explode( '/', $key );
+ if( count( $pieces ) < 2 )
+ return array( $key, $wgContLanguageCode );
- $key = $pieces[0];
+ $lang = array_pop( $pieces );
+ $validCodes = Language::getLanguageNames();
+ if( !array_key_exists( $lang, $validCodes ) )
+ return array( $key, $wgContLanguageCode );
- # Language the user is translating to
- $langCode = isset($pieces[1]) ? $pieces[1] : $wgContLanguageCode;
- return array( $key, $langCode );
+ $message = implode( '/', $pieces );
+ return array( $message, $lang );
}
}