r37058 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37057‎ | r37058 | r37059 >
Date:15:01, 4 July 2008
Author:shinjiman
Status:old
Tags:
Comment:
* (bug 14604) Update LanguageConverter for T (Title) conversion
bugzilla attachment 5048
patch by fdcn
* Localisation updates Cantonese, Chinese and Old/Late Time Chinese
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hans.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hant.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_tw.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -219,9 +219,9 @@
220220 3. place holders created by the parser
221221 */
222222 global $wgParser;
223 - if (isset($wgParser) && $wgParser->UniqPrefix()!='')
 223+ if (isset($wgParser) && $wgParser->UniqPrefix()!=''){
224224 $marker = '|' . $wgParser->UniqPrefix() . '[\-a-zA-Z0-9]+';
225 - else
 225+ } else
226226 $marker = "";
227227
228228 // this one is needed when the text is inside an html markup
@@ -231,8 +231,10 @@
232232 $codefix = '<code>.+?<\/code>|';
233233 // disable convertsion of <script type="text/javascript"> ... </script>
234234 $scriptfix = '<script.*?>.*?<\/script>|';
 235+ // disable conversion of <pre xxxx> ... </pre>
 236+ $prefix = '<pre.*?>.*?<\/pre>|';
235237
236 - $reg = '/'.$codefix . $scriptfix . '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s';
 238+ $reg = '/'.$codefix . $scriptfix . $prefix . '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s';
237239
238240 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
239241
@@ -256,6 +258,7 @@
257259 * @param string $text Text to convert
258260 * @param string $variant Variant language code
259261 * @return string Translated text
 262+ * @private
260263 */
261264 function translate( $text, $variant ) {
262265 wfProfileIn( __METHOD__ );
@@ -323,6 +326,7 @@
324327
325328 /**
326329 * Convert text using a parser object for context
 330+ * @public
327331 */
328332 function parserConvert( $text, &$parser ) {
329333 global $wgDisableLangConversion;
@@ -343,7 +347,7 @@
344348
345349 /**
346350 * Parse flags with syntax -{FLAG| ... }-
347 - *
 351+ * @private
348352 */
349353 function parseFlags($marked){
350354 $flags = array();
@@ -400,17 +404,19 @@
401405 }
402406 if ( count($flags)==0 )
403407 $flags = array('S');
404 -
405408 return array($rules,$flags);
406409 }
407410
 411+ /**
 412+ * @private
 413+ */
408414 function getRulesDesc($bidtable,$unidtable){
409415 $text='';
410416 foreach($bidtable as $k => $v)
411417 $text .= $this->mVariantNames[$k].':'.$v.';';
412418 foreach($unidtable as $k => $a)
413419 foreach($a as $from=>$to)
414 - $text.=$from.'⇒'.$this->mVariantNames[$k].':'.$to.';';
 420+ $text.=$from.'⇁E.$this->mVariantNames[$k].':'.$to.';';
415421 return $text;
416422 }
417423
@@ -474,8 +480,9 @@
475481 // proces H,- flag or T only: output nothing
476482 $disp = '';
477483 } elseif ( in_array('S',$flags) ){
478 - // the text converted
479 - if($doConvert){
 484+ if( count($bidtable) + count($unidtable) == 0 ){
 485+ $disp = $rules;
 486+ } elseif ($doConvert){// the text converted
480487 // display current variant in bidirectional array
481488 $disp = $this->getTextInCArray($variant,$bidtable);
482489 // or display current variant in fallbacks
@@ -495,7 +502,7 @@
496503 $disp = array_values($unidtable);
497504 $disp = array_values($disp[0]);
498505 $disp = $disp[0];
499 - }
 506+ }
500507 }
501508 } else {// no convert
502509 $disp = $rules;
@@ -510,7 +517,10 @@
511518 return $disp;
512519 }
513520
514 - function applyManualFlag($flags,$bidtable,$unidtable,$variant=false){
 521+ /**
 522+ * @access private
 523+ */
 524+ function applyManualFlag($rules,$flags,$bidtable,$unidtable,$variant=false){
515525 if(!$variant) $variant = $this->getPreferredVariant();
516526
517527 $is_title_flag = in_array('T', $flags);
@@ -582,11 +592,15 @@
583593 $bidtable,$unidtable,
584594 $variant,
585595 $this->mDoContentConvert);
586 - $this->applyManualFlag($flags,$bidtable,$unidtable);
 596+ $this->applyManualFlag($rules,$flags,$bidtable,$unidtable);
587597
588598 return $disp;
589599 }
590600
 601+ /**
 602+ * convert title
 603+ * @private
 604+ */
591605 function convertTitle($text){
592606 // check for __NOTC__ tag
593607 if( !$this->mDoTitleConvert ) {
@@ -931,6 +945,7 @@
932946 *
933947 * @param string $text text to be tagged for no conversion
934948 * @return string the tagged text
 949+ * @public
935950 */
936951 function markNoConversion($text, $noParse=false) {
937952 # don't mark if already marked
@@ -972,6 +987,7 @@
973988 /**
974989 * Armour rendered math against conversion
975990 * Wrap math into rawoutput -{R| math }- syntax
 991+ * @public
976992 */
977993 function armourMath($text){
978994 $ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end'];
Index: trunk/phase3/languages/messages/MessagesZh_hans.php
@@ -1,5 +1,5 @@
22 <?php
3 -/** Simplified Chinese (‪中文(简体)‬)
 3+/** Chinese (Simplified) (‪中文 (简化字)‬)
44 *
55 * @ingroup Language
66 * @file
Index: trunk/phase3/languages/messages/MessagesZh_hant.php
@@ -1,5 +1,5 @@
22 <?php
3 -/** Traditional Chinese (‪中文(繁體)‬)
 3+/** Traditional Chinese (‪中文(傳統字)‬)
44 *
55 * @ingroup Language
66 * @file
Index: trunk/phase3/languages/messages/MessagesZh_tw.php
@@ -1,5 +1,5 @@
22 <?php
3 -/** Taiwan Chinese (‪中文(台灣)‬)
 3+/** ‪Chinese (Taiwan) (‪中文(台灣)‬)
44 *
55 * @ingroup Language
66 * @file

Follow-up revisions

RevisionCommit summaryAuthorDate
r37059fix encoding problems on r37058shinjiman15:17, 4 July 2008
r37186(bug 14604#c6): Fix regression in variant conversion when semicolon is within...rainman17:23, 6 July 2008
r37373* (bug 14604) Update LanguageConverter for compatibility on -{*|xxx}- usage...shinjiman08:16, 9 July 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r36664* (bug 14604) Introduced the following features for the LanguageConverter: Mu...shinjiman03:00, 26 June 2008

Status & tagging log