Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | var $mKeys, $mParserOptions, $mParser; |
27 | 27 | var $mExtensionMessages = array(); |
28 | 28 | var $mInitialised = false; |
29 | | - var $mAllMessagesLoaded; // Extension messages |
| 29 | + var $mAllMessagesLoaded = array(); // Extension messages |
30 | 30 | |
31 | 31 | // Variable for tracking which variables are loaded |
32 | 32 | var $mLoadedLanguages = array(); |
— | — | @@ -766,12 +766,13 @@ |
767 | 767 | } |
768 | 768 | } |
769 | 769 | |
770 | | - function loadAllMessages() { |
| 770 | + function loadAllMessages( $lang = false ) { |
771 | 771 | global $wgExtensionMessagesFiles; |
772 | | - if ( $this->mAllMessagesLoaded ) { |
| 772 | + $key = $lang === false ? '*' : $lang; |
| 773 | + if ( isset( $this->mAllMessagesLoaded[$key] ) ) { |
773 | 774 | return; |
774 | 775 | } |
775 | | - $this->mAllMessagesLoaded = true; |
| 776 | + $this->mAllMessagesLoaded[$key] = true; |
776 | 777 | |
777 | 778 | # Some extensions will load their messages when you load their class file |
778 | 779 | wfLoadAllExtensions(); |
— | — | @@ -779,7 +780,7 @@ |
780 | 781 | wfRunHooks( 'LoadAllMessages' ); |
781 | 782 | # Some register their messages in $wgExtensionMessagesFiles |
782 | 783 | foreach ( $wgExtensionMessagesFiles as $name => $file ) { |
783 | | - wfLoadExtensionMessages( $name ); |
| 784 | + wfLoadExtensionMessages( $name, $lang ); |
784 | 785 | } |
785 | 786 | # Still others will respond to neither, they are EVIL. We sometimes need to know! |
786 | 787 | } |
— | — | @@ -840,13 +841,17 @@ |
841 | 842 | |
842 | 843 | public function figureMessage( $key ) { |
843 | 844 | global $wgContLanguageCode; |
844 | | - $pieces = explode('/', $key, 2); |
| 845 | + $pieces = explode( '/', $key ); |
| 846 | + if( count( $pieces ) < 2 ) |
| 847 | + return array( $key, $wgContLanguageCode ); |
845 | 848 | |
846 | | - $key = $pieces[0]; |
| 849 | + $lang = array_pop( $pieces ); |
| 850 | + $validCodes = Language::getLanguageNames(); |
| 851 | + if( !array_key_exists( $lang, $validCodes ) ) |
| 852 | + return array( $key, $wgContLanguageCode ); |
847 | 853 | |
848 | | - # Language the user is translating to |
849 | | - $langCode = isset($pieces[1]) ? $pieces[1] : $wgContLanguageCode; |
850 | | - return array( $key, $langCode ); |
| 854 | + $message = implode( '/', $pieces ); |
| 855 | + return array( $message, $lang ); |
851 | 856 | } |
852 | 857 | |
853 | 858 | } |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | * @private |
112 | 112 | */ |
113 | 113 | function getContent( $def_text = '' ) { |
114 | | - global $wgOut, $wgRequest, $wgParser, $wgMessageCache; |
| 114 | + global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache; |
115 | 115 | |
116 | 116 | wfProfileIn( __METHOD__ ); |
117 | 117 | # Get variables from query string :P |
— | — | @@ -124,9 +124,12 @@ |
125 | 125 | // For other non-existent articles, use preload text if any. |
126 | 126 | if ( !$this->mTitle->exists() ) { |
127 | 127 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
128 | | - $wgMessageCache->loadAllMessages(); |
129 | 128 | # If this is a system message, get the default text. |
130 | | - $text = wfMsgWeirdKey( $this->mTitle->getText() ) ; |
| 129 | + list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); |
| 130 | + $wgMessageCache->loadAllMessages( $lang ); |
| 131 | + $text = wfMsgGetKey( $message, false, $lang, false ); |
| 132 | + if( wfEmptyMsg( $message, $text ) ) |
| 133 | + $text = ''; |
131 | 134 | } else { |
132 | 135 | # If requested, preload some text. |
133 | 136 | $text = $this->getPreloadedText( $preload ); |
— | — | @@ -1044,11 +1047,8 @@ |
1045 | 1048 | */ |
1046 | 1049 | function initialiseForm() { |
1047 | 1050 | $this->edittime = $this->mArticle->getTimestamp(); |
1048 | | - $this->textbox1 = $this->getContent(false); |
1049 | | - if ( $this->textbox1 === false) return false; |
1050 | | - |
1051 | | - if ( !$this->mArticle->exists() && $this->mTitle->getNamespace() == NS_MEDIAWIKI ) |
1052 | | - $this->textbox1 = wfMsgWeirdKey( $this->mTitle->getText() ); |
| 1051 | + $this->textbox1 = $this->getContent( false ); |
| 1052 | + if ( $this->textbox1 === false ) return false; |
1053 | 1053 | wfProxyCheck(); |
1054 | 1054 | return true; |
1055 | 1055 | } |