Index: trunk/phase3/maintenance/InitialiseMessages.inc |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | global $IP; |
21 | 21 | |
22 | 22 | # overwrite language conversion option so that all variants |
23 | | - # of the selected language are initialised |
| 23 | + # of the messages are initialised |
24 | 24 | $wgDisableLangConversion = false; |
25 | 25 | |
26 | 26 | if ( $messageArray ) { |
— | — | @@ -31,36 +31,26 @@ |
32 | 32 | ksort( $sortedArray ); |
33 | 33 | $messages=array(); |
34 | 34 | |
35 | | - /* check special case where the language does |
36 | | - not have a language file |
37 | | - */ |
38 | | - if( get_class($wgContLang) != 'language'.strtolower($wgContLanguageCode) ) { |
| 35 | + $variants = $wgContLang->getVariants(); |
| 36 | + if(!in_array($wgContLanguageCode, $variants)) |
| 37 | + $variants[]=$wgContLanguageCode; |
| 38 | + |
| 39 | + foreach ($variants as $v) { |
| 40 | + $langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) ); |
| 41 | + if( !class_exists($langclass) ) { |
| 42 | + die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?"); |
| 43 | + } |
| 44 | + $lang = new $langclass; |
| 45 | + |
| 46 | + if($v==$wgContLanguageCode) |
| 47 | + $suffix=''; |
| 48 | + else |
| 49 | + $suffix="/$v"; |
39 | 50 | foreach ($sortedArray as $key => $msg) { |
40 | | - $messages[$key] = $wgContLang->getMessage($key); |
| 51 | + $messages[$key.$suffix] = $lang->getMessage($key); |
41 | 52 | } |
42 | 53 | } |
43 | | - else { |
44 | | - $variants = $wgContLang->getVariants(); |
45 | | - if(!in_array($wgContLanguageCode, $variants)) |
46 | | - $variants[]=$wgContLanguageCode; |
47 | 54 | |
48 | | - foreach ($variants as $v) { |
49 | | - $langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) ); |
50 | | - if( !class_exists($langclass) ) { |
51 | | - die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?"); |
52 | | - } |
53 | | - $lang = new $langclass; |
54 | | - |
55 | | - if($v==$wgContLanguageCode) |
56 | | - $suffix=''; |
57 | | - else |
58 | | - $suffix="/$v"; |
59 | | - foreach ($sortedArray as $key => $msg) { |
60 | | - $messages[$key.$suffix] = $lang->getMessage($key); |
61 | | - } |
62 | | - } |
63 | | - } |
64 | | - |
65 | 55 | initialiseMessagesReal( $overwrite, $messages ); |
66 | 56 | } |
67 | 57 | |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -378,46 +378,16 @@ |
379 | 379 | $fname = 'wfMsgReal'; |
380 | 380 | wfProfileIn( $fname ); |
381 | 381 | |
382 | | - if( $forContent ) { |
383 | | - /** |
384 | | - * Message is needed for page content, and needs |
385 | | - * to be consistent with the site's configured |
386 | | - * language. It might be part of a page title, |
387 | | - * or a link, or text that will go into the |
388 | | - * parser cache and be served back to other |
389 | | - * visitors. |
390 | | - */ |
391 | | - $cache = &$wgMessageCache; |
392 | | - $lang = &$wgContLang; |
393 | | - } else { |
394 | | - /** |
395 | | - * Message is for display purposes only. |
396 | | - * The user may have selected a conversion-based |
397 | | - * language variant or a separate user interface |
398 | | - * language; if so use that. |
399 | | - */ |
400 | | - if ( is_object( $wgContLang ) ) { |
401 | | - if( in_array( $wgLanguageCode, $wgContLang->getVariants() ) ) { |
402 | | - $cache = &$wgMessageCache; |
403 | | - $lang = &$wgLang; |
404 | | - } else { |
405 | | - $cache = false; |
406 | | - $lang = &$wgLang; |
407 | | - } |
| 382 | + if( is_object( $wgMessageCache ) ) { |
| 383 | + $message = $wgMessageCache->get( $key, $useDB, $forContent ); |
| 384 | + } |
| 385 | + else { |
| 386 | + if( $forContent ) { |
| 387 | + $lang = &$wgContLang; |
408 | 388 | } else { |
409 | | - $cache = false; |
410 | | - $lang = false; |
| 389 | + $lang = &$wgLang; |
411 | 390 | } |
412 | | - } |
413 | 391 | |
414 | | - |
415 | | - if( is_object( $cache ) ) { |
416 | | - $message = $cache->get( $key, $useDB, $forContent ); |
417 | | - } else { |
418 | | - if ( !is_object( $lang ) ) { |
419 | | - $lang = new Language; |
420 | | - } |
421 | | - |
422 | 392 | wfSuppressWarnings(); |
423 | 393 | $message = $lang->getMessage( $key ); |
424 | 394 | wfRestoreWarnings(); |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -239,28 +239,29 @@ |
240 | 240 | wfProfileOut( $fname.'-User' ); |
241 | 241 | wfProfileIn( $fname.'-language2' ); |
242 | 242 | |
243 | | -function setupLangObj(&$langclass, $langcode) { |
| 243 | +function setupLangObj(&$langclass) { |
244 | 244 | global $wgUseLatin1, $IP; |
245 | 245 | |
| 246 | + if( ! class_exists( $langclass ) ) { |
| 247 | + # Default to English/UTF-8, or for non-UTF-8, to latin-1 |
| 248 | + $baseclass = 'LanguageUtf8'; |
| 249 | + if( $wgUseLatin1 ) |
| 250 | + $baseclass = 'LanguageLatin1'; |
| 251 | + require_once( "$IP/languages/$baseclass.php" ); |
| 252 | + $lc = strtolower(substr($langclass, 8)); |
| 253 | + $snip = " |
| 254 | + class $langclass extends $baseclass { |
| 255 | + function getVariants() { |
| 256 | + return array(\"$lc\"); |
| 257 | + } |
246 | 258 | |
247 | | - if( ! class_exists( $langclass ) ) { |
248 | | - # Default to English/UTF-8 |
249 | | - require_once( "$IP/languages/LanguageUtf8.php" ); |
250 | | - $langclass = 'LanguageUtf8'; |
| 259 | + }"; |
| 260 | + |
| 261 | + eval($snip); |
251 | 262 | } |
252 | 263 | |
253 | 264 | $lang = new $langclass(); |
254 | | - if ( !is_object($lang) ) { |
255 | | - print "No language class ($wgLang)\N"; |
256 | | - } |
257 | 265 | |
258 | | - if( $wgUseLatin1 ) { |
259 | | - # For non-UTF-8 latin-1 downconversion |
260 | | - require_once( "$IP/languages/LanguageLatin1.php" ); |
261 | | - $xxx = new LanguageLatin1( $lang ); |
262 | | - unset( $lang ); |
263 | | - $lang = $xxx; |
264 | | - } |
265 | 266 | return $lang; |
266 | 267 | } |
267 | 268 | |
— | — | @@ -270,8 +271,7 @@ |
271 | 272 | $wgContLanguageCode = $wgLanguageCode; |
272 | 273 | $wgContLangClass = 'Language' . str_replace( '-', '_', ucfirst( $wgContLanguageCode ) ); |
273 | 274 | |
274 | | -$wgContLang = setupLangObj( $wgContLangClass, $wgContLangClass ); |
275 | | -$n = get_class($wgContLang); |
| 275 | +$wgContLang = setupLangObj( $wgContLangClass ); |
276 | 276 | |
277 | 277 | // set default user option from content language |
278 | 278 | if( !$wgUser->mDataLoaded ) { |
— | — | @@ -286,11 +286,13 @@ |
287 | 287 | if( $wgLangClass == $wgContLangClass ) { |
288 | 288 | $wgLang = &$wgContLang; |
289 | 289 | } else { |
290 | | - require_once("$IP/languages/$wgLangClass.php"); |
291 | | - $wgLang = setupLangObj( $wgLangClass, $wgLanguageCode ); |
| 290 | + wfSuppressWarnings(); |
| 291 | + include_once("$IP/languages/$wgLangClass.php"); |
| 292 | + wfRestoreWarnings(); |
| 293 | + |
| 294 | + $wgLang = setupLangObj( $wgLangClass ); |
292 | 295 | } |
293 | 296 | |
294 | | - |
295 | 297 | wfProfileOut( $fname.'-language' ); |
296 | 298 | wfProfileIn( $fname.'-MessageCache' ); |
297 | 299 | |
Index: trunk/phase3/includes/SpecialAllmessages.php |
— | — | @@ -13,12 +13,6 @@ |
14 | 14 | global $wgLanguageCode, $wgContLanguageCode, $wgContLang; |
15 | 15 | global $wgUseDatabaseMessages; |
16 | 16 | |
17 | | - if($wgLanguageCode != $wgContLanguageCode && |
18 | | - !in_array($wgLanguageCode, $wgContLang->getVariants())) { |
19 | | - $err = wfMsg('allmessagesnotsupportedUI', $wgLanguageCode); |
20 | | - $wgOut->addHTML( $err ); |
21 | | - return; |
22 | | - } |
23 | 17 | if(!$wgUseDatabaseMessages) { |
24 | 18 | $wgOut->addHTML(wfMsg('allmessagesnotsupportedDB')); |
25 | 19 | return; |
— | — | @@ -94,7 +88,7 @@ |
95 | 89 | * |
96 | 90 | */ |
97 | 91 | function makeHTMLText( $messages ) { |
98 | | - global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode; |
| 92 | + global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode, $wgContLang; |
99 | 93 | $fname = "makeHTMLText"; |
100 | 94 | wfProfileIn( $fname ); |
101 | 95 | |
— | — | @@ -128,11 +122,13 @@ |
129 | 123 | wfProfileOut( "$fname-check" ); |
130 | 124 | |
131 | 125 | wfProfileIn( "$fname-output" ); |
| 126 | + |
132 | 127 | foreach( $messages as $key => $m ) { |
133 | 128 | |
134 | 129 | $title = $wgLang->ucfirst( $key ); |
135 | 130 | if($wgLanguageCode != $wgContLanguageCode) |
136 | 131 | $title.="/$wgLanguageCode"; |
| 132 | + |
137 | 133 | $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title ); |
138 | 134 | $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title ); |
139 | 135 | |
Index: trunk/phase3/includes/SpecialPreferences.php |
— | — | @@ -323,7 +323,7 @@ |
324 | 324 | global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames; |
325 | 325 | global $wgAllowRealName, $wgImageLimits; |
326 | 326 | global $wgLanguageNames, $wgDisableLangConversion; |
327 | | - |
| 327 | + global $wgContLanguageCode; |
328 | 328 | $wgOut->setPageTitle( wfMsg( 'preferences' ) ); |
329 | 329 | $wgOut->setArticleRelated( false ); |
330 | 330 | $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
— | — | @@ -417,7 +417,7 @@ |
418 | 418 | global $IP; |
419 | 419 | /* only add languages that have a file */ |
420 | 420 | $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php"; |
421 | | - if(file_exists($langfile)) { |
| 421 | + if(file_exists($langfile) || $code == $wgContLanguageCode) { |
422 | 422 | $sel = ($code == $this->mUserLanguage)? 'selected="selected"' : ''; |
423 | 423 | $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n"); |
424 | 424 | } |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -2184,20 +2184,14 @@ |
2185 | 2185 | // utf8 if the language does not have a language file) |
2186 | 2186 | $v = $this->getVariants(); |
2187 | 2187 | if( !empty( $v ) ) { |
2188 | | - foreach ($v as $v2) { |
2189 | | - if($v2 != 'utf8') { |
2190 | | - $lang = $v2; |
2191 | | - break; |
2192 | | - } |
2193 | | - } |
| 2188 | + return $v[0]; |
2194 | 2189 | } |
2195 | 2190 | if($lang != '') |
2196 | 2191 | return $lang; |
2197 | 2192 | |
2198 | 2193 | // get it from the class name |
2199 | 2194 | $lang = strtolower( substr( get_class( $this ), 8 ) ); |
2200 | | - if($lang == 'utf8') |
2201 | | - $lang = 'en'; |
| 2195 | + |
2202 | 2196 | return $lang; |
2203 | 2197 | } |
2204 | 2198 | |