r48019 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48018‎ | r48019 | r48020 >
Date:11:53, 4 March 2009
Author:philip
Status:ok
Tags:
Comment:
Allowed ";" exists in manual conversion rules.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -998,23 +998,30 @@
999999 $bidtable = array();
10001000 $unidtable = array();
10011001 $markup = $this->mConverter->mMarkup;
 1002+ $variants = $this->mConverter->mVariants;
10021003
1003 - $choice = explode($markup['varsep'], $rules);
1004 - foreach($choice as $c) {
 1004+ $varsep_pattern = '/' . $markup['varsep'] . '\s*' . '(?=';
 1005+ foreach( $variants as $variant )
 1006+ $varsep_pattern .= $variant . '\s*' . $markup['codesep'] . '|';
 1007+ $varsep_pattern .= '\s*$)/';
 1008+
 1009+ $choice = preg_split($varsep_pattern, $rules);
 1010+ foreach( $choice as $c ) {
10051011 $v = explode($markup['codesep'], $c, 2);
10061012 if( count($v) != 2 )
10071013 continue;// syntax error, skip
10081014 $to = trim($v[1]);
10091015 $v = trim($v[0]);
10101016 $u = explode($markup['unidsep'], $v);
1011 - if( count($u) == 1 ) {
 1017+ if( count($u) == 1 && $to && in_array( $v, $variants ) ) {
10121018 $bidtable[$v] = $to;
10131019 } else if(count($u) == 2){
10141020 $from = trim($u[0]);
10151021 $v = trim($u[1]);
1016 - if( array_key_exists( $v, $unidtable ) && !is_array( $unidtable[$v] ) )
 1022+ if( array_key_exists( $v, $unidtable ) && !is_array( $unidtable[$v] )
 1023+ && $to && in_array( $v, $variants ) )
10171024 $unidtable[$v] = array( $from=>$to );
1018 - else
 1025+ elseif ( $to && in_array( $v, $variants ) )
10191026 $unidtable[$v][$from] = $to;
10201027 }
10211028 // syntax error, pass
@@ -1158,10 +1165,6 @@
11591166 }
11601167
11611168 if( !in_array( 'R', $flags ) || !in_array( 'N', $flags ) ) {
1162 - //FIXME: may cause trouble here...
1163 - //strip   since it interferes with the parsing, plus,
1164 - //all spaces should be stripped in this tag anyway.
1165 - $this->mRules = str_replace(' ', '', $this->mRules);
11661169 // decode => HTML entities modified by Sanitizer::removeHTMLtags
11671170 $this->mRules = str_replace('=>','=>',$this->mRules);
11681171
Index: trunk/phase3/RELEASE-NOTES
@@ -276,6 +276,8 @@
277277 * (bug 17529) rvend ignored when rvstartid is specified
278278 * (bug 17626) Added uiprop=email to list=userinfo
279279 * (bug 13209) Added rvdiffto parameter to prop=revisions
 280+* Manual language conversion improve: Now we can include both ";" and ":" in
 281+ conversion rules
280282
281283 === Languages updated in 1.15 ===
282284

Status & tagging log