Index: branches/REL1_4/phase3/RELEASE-NOTES |
— | — | @@ -451,7 +451,10 @@ |
452 | 452 | * (bug 1736) typo in SpecialValidate.php |
453 | 453 | * (bug 73) Upload doesn't run edit updates on description page (links, |
454 | 454 | search index and categories) |
| 455 | +* Support for manually converting article title to different Chinese |
| 456 | + variants (for zh) |
455 | 457 | |
| 458 | + |
456 | 459 | === Caveats === |
457 | 460 | |
458 | 461 | Some output, particularly involving user-supplied inline HTML, may not |
Index: branches/REL1_4/phase3/languages/LanguageZh.php |
— | — | @@ -40,6 +40,7 @@ |
41 | 41 | var $mTablesLoaded = false; |
42 | 42 | var $mCacheKey; |
43 | 43 | var $mDoTitleConvert = true, $mDoContentConvert = true; |
| 44 | + var $mTitleDisplay=false; |
44 | 45 | function LanguageZh() { |
45 | 46 | global $wgDBname; |
46 | 47 | $this->mCacheKey = $wgDBname . ":zhtables"; |
— | — | @@ -320,6 +321,8 @@ |
321 | 322 | if( $isTitle ) { |
322 | 323 | if( !$this->mDoTitleConvert ) |
323 | 324 | return $text; |
| 325 | + if( $this->mTitleDisplay!=false ) |
| 326 | + return $this->mTitleDisplay; |
324 | 327 | |
325 | 328 | global $wgRequest; |
326 | 329 | $isredir = $wgRequest->getText( 'redirect', 'yes' ); |
— | — | @@ -343,11 +346,28 @@ |
344 | 347 | $text = $this->autoConvert($tfirst); |
345 | 348 | foreach($tarray as $txt) { |
346 | 349 | $marked = explode("}-", $txt); |
347 | | - |
348 | | - $choice = explode(";", $marked{0}); |
| 350 | + |
| 351 | + //strip since it interferes with the parsing, plus, |
| 352 | + //all spaces should be stripped in this tag anyway. |
| 353 | + $marked[0] = str_replace(' ', '', $marked[0]); |
| 354 | + |
| 355 | + /* see if this conversion is specifically for the |
| 356 | + article title. the format is |
| 357 | + -{T|zh-cn:foo; zh-tw:bar}- |
| 358 | + */ |
| 359 | + $fortitle = false; |
| 360 | + $tt = explode("|", $marked[0], 2); |
| 361 | + if(sizeof($tt) == 2 && trim($tt[0]) == 'T') { |
| 362 | + $choice = explode(";", $tt[1]); |
| 363 | + $fortitle = true; |
| 364 | + } |
| 365 | + else { |
| 366 | + $choice = explode(";", $marked[0]); |
| 367 | + } |
| 368 | + $disp = ''; |
349 | 369 | if(!array_key_exists(1, $choice)) { |
350 | 370 | /* a single choice */ |
351 | | - $text .= $choice{0}; |
| 371 | + $disp = $choice[0]; |
352 | 372 | } else { |
353 | 373 | $choice1=false; |
354 | 374 | $choice2=false; |
— | — | @@ -357,8 +377,8 @@ |
358 | 378 | //syntax error in the markup, give up |
359 | 379 | break; |
360 | 380 | } |
361 | | - $code = trim($v{0}); |
362 | | - $content = trim($v{1}); |
| 381 | + $code = trim($v[0]); |
| 382 | + $content = trim($v[1]); |
363 | 383 | if($code == $plang) { |
364 | 384 | $choice1 = $content; |
365 | 385 | break; |
— | — | @@ -367,14 +387,18 @@ |
368 | 388 | $choice2 = $content; |
369 | 389 | } |
370 | 390 | if ( $choice1 ) |
371 | | - $text .= $choice1; |
| 391 | + $disp = $choice1; |
372 | 392 | elseif ( $choice2 ) |
373 | | - $text .= $choice2; |
| 393 | + $disp = $choice2; |
374 | 394 | else |
375 | | - $text .= $marked{0}; |
| 395 | + $disp = $marked[0]; |
376 | 396 | } |
| 397 | + if($fortitle) |
| 398 | + $this->mTitleDisplay = $disp; |
| 399 | + else |
| 400 | + $text .= $disp; |
377 | 401 | if(array_key_exists(1, $marked)) |
378 | | - $text .= $this->autoConvert($marked{1}); |
| 402 | + $text .= $this->autoConvert($marked[1]); |
379 | 403 | } |
380 | 404 | |
381 | 405 | return $text; |