Index: trunk/phase3/maintenance/InitialiseMessages.inc |
— | — | @@ -12,8 +12,50 @@ |
13 | 13 | * @subpackage Maintenance |
14 | 14 | */ |
15 | 15 | |
| 16 | + |
| 17 | + |
| 18 | +function initialiseMessages( $overwrite = false, $messageArray = false ) { |
| 19 | + global $wgContLang, $wgContLanguageCode; |
| 20 | + global $wgContLangClass, $wgAllMessagesEn; |
| 21 | + |
| 22 | + $langclass = 'Language'. str_replace( '-', '_', ucfirst( $wgContLanguageCode ) ); |
| 23 | + require_once("languages/$langclass.php"); |
| 24 | + |
| 25 | + $variants = $wgContLang->getVariants(); |
| 26 | + if(!in_array($wgContLanguageCode, $variants)) |
| 27 | + $variants[]=$wgContLanguageCode; |
| 28 | + |
| 29 | + if ( $messageArray ) { |
| 30 | + $sortedArray = $messageArray; |
| 31 | + } else { |
| 32 | + $sortedArray = $wgAllMessagesEn; |
| 33 | + } |
| 34 | + |
| 35 | + ksort( $sortedArray ); |
| 36 | + |
| 37 | + $messages=array(); |
| 38 | + foreach ($variants as $v) { |
| 39 | + $langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) ); |
| 40 | + $lang = new $langclass; |
| 41 | + if(!is_object($lang)) { |
| 42 | + die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?"); |
| 43 | + } |
| 44 | + foreach ($sortedArray as $key => $msg) { |
| 45 | + $messages[$key."/$v"] = $lang->getMessage($key); |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + initialiseMessagesReal( $overwrite, $messages ); |
| 50 | +} |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
16 | 58 | /** */ |
17 | | -function initialiseMessages( $overwrite = false, $messageArray = false ) { |
| 59 | +function initialiseMessagesReal( $overwrite = false, $messageArray = false ) { |
18 | 60 | global $wgContLang, $wgScript, $wgServer, $wgAllMessagesEn; |
19 | 61 | global $wgOut, $wgArticle, $wgUser; |
20 | 62 | global $wgMessageCache, $wgMemc, $wgDBname, $wgUseMemCached; |
Index: trunk/phase3/includes/SpecialAllmessages.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | */ |
12 | 12 | function wfSpecialAllmessages() { |
13 | 13 | global $wgOut, $wgAllMessagesEn, $wgRequest, $wgMessageCache, $wgTitle; |
14 | | - |
| 14 | + global $wgLanguageCode, $wgContLanguageCode, $wgContLang; |
15 | 15 | $fname = "wfSpecialAllMessages"; |
16 | 16 | wfProfileIn( $fname ); |
17 | 17 | |
— | — | @@ -19,6 +19,14 @@ |
20 | 20 | $mwMsg =& MagicWord::get( MAG_MSG ); |
21 | 21 | |
22 | 22 | $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) ); |
| 23 | + |
| 24 | + if($wgLanguageCode != $wgContLanguageCode && |
| 25 | + !in_array($wgLanguageCode, $wgContLang->getVariants())) { |
| 26 | + $err = wfMsg('allmessagesnotsupported'); |
| 27 | + $wgOut->addHTML( $err ); |
| 28 | + return; |
| 29 | + } |
| 30 | + |
23 | 31 | $first = true; |
24 | 32 | $sortedArray = $wgAllMessagesEn; |
25 | 33 | ksort( $sortedArray ); |
— | — | @@ -27,8 +35,8 @@ |
28 | 36 | |
29 | 37 | foreach ( $sortedArray as $key => $enMsg ) { |
30 | 38 | $messages[$key]['enmsg'] = $enMsg; |
31 | | - $messages[$key]['statmsg'] = wfMsgNoDbForContent( $key ); |
32 | | - $messages[$key]['msg'] = wfMsgForContent ( $key ); |
| 39 | + $messages[$key]['statmsg'] = wfMsgNoDb( $key ); |
| 40 | + $messages[$key]['msg'] = wfMsg ( $key ); |
33 | 41 | } |
34 | 42 | |
35 | 43 | $wgMessageCache->enableTransform(); |
— | — | @@ -79,7 +87,7 @@ |
80 | 88 | * |
81 | 89 | */ |
82 | 90 | function makeHTMLText( $messages ) { |
83 | | - global $wgLang, $wgUser; |
| 91 | + global $wgLang, $wgUser, $wgLanguageCode; |
84 | 92 | $fname = "makeHTMLText"; |
85 | 93 | wfProfileIn( $fname ); |
86 | 94 | |
— | — | @@ -114,7 +122,8 @@ |
115 | 123 | |
116 | 124 | wfProfileIn( "$fname-output" ); |
117 | 125 | foreach( $messages as $key => $m ) { |
118 | | - $title = $wgLang->ucfirst( $key ); |
| 126 | + |
| 127 | + $title = $wgLang->ucfirst( $key )."/$wgLanguageCode"; |
119 | 128 | $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title ); |
120 | 129 | $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title ); |
121 | 130 | |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -420,22 +420,29 @@ |
421 | 421 | */ |
422 | 422 | function wfMsgReal( $key, $args, $useDB, $forContent=false ) { |
423 | 423 | global $wgReplacementKeys, $wgParser, $wgMsgParserOptions; |
424 | | - |
| 424 | + global $wgContLang, $wgLanguageCode; |
425 | 425 | if($forContent) { |
426 | | - global $wgMessageCache, $wgContLang; |
| 426 | + global $wgMessageCache; |
427 | 427 | $cache = &$wgMessageCache; |
428 | 428 | $lang = &$wgContLang; |
429 | 429 | } |
430 | 430 | else { |
431 | | - global $wgLang; |
432 | | - $cache = false; |
433 | | - $lang = &$wgLang; |
| 431 | + if(in_array($wgLanguageCode, $wgContLang->getVariants())){ |
| 432 | + global $wgLang, $wgMessageCache; |
| 433 | + $cache = &$wgMessageCache; |
| 434 | + $lang = $wgLang; |
| 435 | + } |
| 436 | + else { |
| 437 | + global $wgLang; |
| 438 | + $cache = false; |
| 439 | + $lang = &$wgLang; |
| 440 | + } |
434 | 441 | } |
435 | 442 | |
436 | 443 | $fname = 'wfMsg'; |
437 | 444 | wfProfileIn( $fname ); |
438 | 445 | if ( is_object($cache) ) { |
439 | | - $message = $cache->get( $key, $useDB ); |
| 446 | + $message = $cache->get( $key, $useDB, $forContent ); |
440 | 447 | } elseif (is_object($lang)) { |
441 | 448 | $message = $lang->getMessage( $key ); |
442 | 449 | if(strstr($message, '{{' ) !== false) { |
Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -198,8 +198,17 @@ |
199 | 199 | $this->mMemc->delete( $lockKey ); |
200 | 200 | } |
201 | 201 | |
202 | | - function get( $key, $useDB ) { |
203 | | - global $wgContLang, $wgContLanguageCode; |
| 202 | + function get( $key, $useDB, $forcontent=true ) { |
| 203 | + if($forcontent) { |
| 204 | + global $wgContLang, $wgContLanguageCode; |
| 205 | + $lang = $wgContLang; |
| 206 | + $langcode = $wgContLanguageCode; |
| 207 | + } |
| 208 | + else { |
| 209 | + global $wgLang, $wgLanguageCode; |
| 210 | + $lang = $wgLang; |
| 211 | + $langcode = $wgLanguageCode; |
| 212 | + } |
204 | 213 | # If uninitialised, someone is trying to call this halfway through Setup.php |
205 | 214 | if ( !$this->mInitialised ) { |
206 | 215 | return "<$key>"; |
— | — | @@ -207,7 +216,7 @@ |
208 | 217 | |
209 | 218 | $message = false; |
210 | 219 | if ( !$this->mDisable && $useDB ) { |
211 | | - $title = $wgContLang->ucfirst( $key ); |
| 220 | + $title = $lang->ucfirst( $key )."/$langcode"; |
212 | 221 | |
213 | 222 | |
214 | 223 | # Try the cache |
— | — | @@ -234,12 +243,12 @@ |
235 | 244 | # Try the array in the language object |
236 | 245 | if ( !$message ) { |
237 | 246 | wfSuppressWarnings(); |
238 | | - $message = $wgContLang->getMessage( $key ); |
| 247 | + $message = $lang->getMessage( $key ); |
239 | 248 | wfRestoreWarnings(); |
240 | 249 | } |
241 | 250 | |
242 | 251 | # Try the English array |
243 | | - if ( !$message && $wgContLanguageCode != 'en' ) { |
| 252 | + if ( !$message && $langcode != 'en' ) { |
244 | 253 | wfSuppressWarnings(); |
245 | 254 | $message = Language::getMessage( $key ); |
246 | 255 | wfRestoreWarnings(); |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | wfProfileOut( $fname.'-includes' ); |
80 | 80 | wfProfileIn( $fname.'-misc1' ); |
81 | 81 | global $wgUser, $wgLang, $wgContLang, $wgOut, $wgTitle; |
| 82 | +global $wgLangClass, $wgContLangClass; |
82 | 83 | global $wgArticle, $wgDeferredUpdateList, $wgLinkCache; |
83 | 84 | global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile; |
84 | 85 | global $wgMessageCache, $wgUseMemCached, $wgUseDatabaseMessages; |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -1398,6 +1398,7 @@ |
1399 | 1399 | |
1400 | 1400 | 'allmessages' => 'All system messages', |
1401 | 1401 | 'allmessagestext' => 'This is a list of all system messages available in the MediaWiki: namespace.', |
| 1402 | +'allmessagesnotsupported' => 'Your current interface language is not supported by Special:AllMessages at this site', |
1402 | 1403 | |
1403 | 1404 | # Thumbnails |
1404 | 1405 | |
Index: trunk/phase3/languages/LanguageZh.php |
— | — | @@ -1,5 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | require_once( "LanguageZh_cn.php"); |
| 4 | +require_once( "LanguageZh_tw.php"); |
4 | 5 | |
5 | 6 | /* caching the conversion tables */ |
6 | 7 | $zhSimp2Trad = $wgMemc->get($key1 = "$wgDBname:zhConvert:s2t"); |