From 81549b37eae59bededf6286019e9a4374349db21 Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Wed, 4 Mar 2009 11:53:45 +0000 Subject: [PATCH] Allowed ";" exists in manual conversion rules. --- RELEASE-NOTES | 2 ++ languages/LanguageConverter.php | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d6546cae3f..87af9fe717 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -276,6 +276,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 17529) rvend ignored when rvstartid is specified * (bug 17626) Added uiprop=email to list=userinfo * (bug 13209) Added rvdiffto parameter to prop=revisions +* Manual language conversion improve: Now we can include both ";" and ":" in + conversion rules === Languages updated in 1.15 === diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 207742ff9e..86b9da9b15 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -998,23 +998,30 @@ class ConverterRule { $bidtable = array(); $unidtable = array(); $markup = $this->mConverter->mMarkup; + $variants = $this->mConverter->mVariants; + + $varsep_pattern = '/' . $markup['varsep'] . '\s*' . '(?='; + foreach( $variants as $variant ) + $varsep_pattern .= $variant . '\s*' . $markup['codesep'] . '|'; + $varsep_pattern .= '\s*$)/'; - $choice = explode($markup['varsep'], $rules); - foreach($choice as $c) { + $choice = preg_split($varsep_pattern, $rules); + foreach( $choice as $c ) { $v = explode($markup['codesep'], $c, 2); if( count($v) != 2 ) continue;// syntax error, skip $to = trim($v[1]); $v = trim($v[0]); $u = explode($markup['unidsep'], $v); - if( count($u) == 1 ) { + if( count($u) == 1 && $to && in_array( $v, $variants ) ) { $bidtable[$v] = $to; } else if(count($u) == 2){ $from = trim($u[0]); $v = trim($u[1]); - if( array_key_exists( $v, $unidtable ) && !is_array( $unidtable[$v] ) ) + if( array_key_exists( $v, $unidtable ) && !is_array( $unidtable[$v] ) + && $to && in_array( $v, $variants ) ) $unidtable[$v] = array( $from=>$to ); - else + elseif ( $to && in_array( $v, $variants ) ) $unidtable[$v][$from] = $to; } // syntax error, pass @@ -1158,10 +1165,6 @@ class ConverterRule { } if( !in_array( 'R', $flags ) || !in_array( 'N', $flags ) ) { - //FIXME: may cause trouble here... - //strip   since it interferes with the parsing, plus, - //all spaces should be stripped in this tag anyway. - $this->mRules = str_replace(' ', '', $this->mRules); // decode => HTML entities modified by Sanitizer::removeHTMLtags $this->mRules = str_replace('=>','=>',$this->mRules); -- 2.20.1