From 0d079d650800d752942d979f20ce1b958470a38f Mon Sep 17 00:00:00 2001 From: Zheng Zhu Date: Sat, 26 Mar 2005 00:54:51 +0000 Subject: [PATCH] (zh) strip   before parsing the -{}- tag; small code clean-up. --- languages/LanguageZh.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/languages/LanguageZh.php b/languages/LanguageZh.php index 61ebde7250..20ed1acd69 100644 --- a/languages/LanguageZh.php +++ b/languages/LanguageZh.php @@ -347,23 +347,29 @@ class LanguageZh extends LanguageZh_cn { $text = $this->autoConvert($tfirst); foreach($tarray as $txt) { $marked = explode("}-", $txt); - $choice = explode(";", $marked{0}); + + //strip   since it interferes with the parsing, plus, + //all spaces should be stripped in this tag anyway. + $marked[0] = str_replace(' ', '', $marked[0]); + + $choice = explode(";", $marked[0]); /* see if this conversion is specifically for the - article title + article title. the format is + -{T|zh-cn:foo;zh-tw:bar}- */ $fortitle = false; - $tt = explode("T|", $marked{0}, 2); - if(sizeof($tt) == 2) { + $tt = explode("|", $marked[0], 2); + if(sizeof($tt) == 2 && trim($tt[0]) == 'T') { $choice = explode(";", $tt[1]); $fortitle = true; } else { - $choice = explode(";", $marked{0}); + $choice = explode(";", $marked[0]); } $disp = ''; if(!array_key_exists(1, $choice)) { /* a single choice */ - $disp = $choice{0}; + $disp = $choice[0]; } else { $choice1=false; $choice2=false; @@ -373,8 +379,8 @@ class LanguageZh extends LanguageZh_cn { //syntax error in the markup, give up break; } - $code = trim($v{0}); - $content = trim($v{1}); + $code = trim($v[0]); + $content = trim($v[1]); if($code == $plang) { $choice1 = $content; break; @@ -387,7 +393,7 @@ class LanguageZh extends LanguageZh_cn { elseif ( $choice2 ) $disp = $choice2; else - $disp = $marked{0}; + $disp = $marked[0]; } if($fortitle) @@ -395,7 +401,7 @@ class LanguageZh extends LanguageZh_cn { else $text .= $disp; if(array_key_exists(1, $marked)) - $text .= $this->autoConvert($marked{1}); + $text .= $this->autoConvert($marked[1]); } return $text; -- 2.20.1