From b6e2dbe230c9dd6ca74cd222937cde7ef95d8f45 Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Fri, 3 Apr 2009 17:35:53 +0000 Subject: [PATCH] 1. Rewrite code for parsing http request header to get supported language variant. Now the current code is written for every language if they do need this. 2. Fixed a bug caused by LanguageConverter.php, which brings an abnormal '}-' after some parsed math syntax. 3. Update the Chinese conversion table. --- RELEASE-NOTES | 2 ++ includes/ZhConversion.php | 7 ++++++- includes/zhtable/simpphrases.manual | 3 ++- includes/zhtable/toTrad.manual | 4 +++- includes/zhtable/tradphrases.manual | 6 ++++-- languages/LanguageConverter.php | 24 ++++++++++++------------ 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d8a0f83107..a236f78894 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -372,6 +372,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added uiprop=changeablegroups to meta=userinfo * Added usprop=gender to list=users * (bug 18311) action=purge now works for images too +* Fixed a bug caused by LanguageConverter.php, which brings an abnormal '}-' + after some parsed math syntax. === Languages updated in 1.15 === diff --git a/includes/ZhConversion.php b/includes/ZhConversion.php index ffffee26ac..f19020e9b3 100644 --- a/includes/ZhConversion.php +++ b/includes/ZhConversion.php @@ -5279,7 +5279,7 @@ $zh2Hant = array( '掌柜' => '掌柜', '排骨面' => '排骨麵', '挂帘' => '掛帘', -'挂钩' => '掛鈎', +'挂钩' => '掛鉤', '挂钟' => '掛鐘', '采下' => '採下', '采伐' => '採伐', @@ -6376,6 +6376,8 @@ $zh2Hant = array( '发签' => '發籤', '发庄' => '發莊', '发着' => '發著', +'发表' => '發表', +'發表' => '發表', '发松' => '發鬆', '发面' => '發麵', '白干' => '白乾', @@ -7055,6 +7057,8 @@ $zh2Hant = array( '英占' => '英佔', '苹萦' => '苹縈', '茂都淀' => '茂都澱', +'范文瀾' => '范文瀾', +'范文澜' => '范文瀾', '范登堡' => '范登堡', '茶几' => '茶几', '茶庄' => '茶莊', @@ -14051,6 +14055,7 @@ $zh2Hans = array( '閑著稱' => '闲著称', '閑著者' => '闲著者', '閑著述' => '闲著述', +'阿部正瞭' => '阿部正瞭', '附著' => '附着', '附睪' => '附睾', '附著書' => '附著书', diff --git a/includes/zhtable/simpphrases.manual b/includes/zhtable/simpphrases.manual index 6758378fc8..e43f7c5ae2 100644 --- a/includes/zhtable/simpphrases.manual +++ b/includes/zhtable/simpphrases.manual @@ -2200,4 +2200,5 @@ 幺谦 麴义 麴英 -麯崇裕 \ No newline at end of file +麯崇裕 +阿部正瞭 \ No newline at end of file diff --git a/includes/zhtable/toTrad.manual b/includes/zhtable/toTrad.manual index b4875d41a7..fd04181fc5 100644 --- a/includes/zhtable/toTrad.manual +++ b/includes/zhtable/toTrad.manual @@ -65,4 +65,6 @@ 不干預 不干預 不干擾 不干擾 不干牠 不干牠 -矽谷 矽谷 \ No newline at end of file +矽谷 矽谷 +范文瀾 范文瀾 +發表 發表 \ No newline at end of file diff --git a/includes/zhtable/tradphrases.manual b/includes/zhtable/tradphrases.manual index d5902eac9f..f83e1d7066 100644 --- a/includes/zhtable/tradphrases.manual +++ b/includes/zhtable/tradphrases.manual @@ -3123,7 +3123,7 @@ 皆可作澱 澱山 澱澱 -掛鈎 +掛鉤 薴悴 絡腮鬍 落腮鬍 @@ -3138,4 +3138,6 @@ 鬍髯 髯鬍 髭鬍 -鬚鬍 \ No newline at end of file +鬚鬍 +范文瀾 +發表 \ No newline at end of file diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index d1c61ed6c9..216623e5ad 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -177,25 +177,22 @@ class LanguageConverter { return $this->mPreferredVariant; } - # FIXME rewrite code for parsing http header. The current code - # is written specific for detecting zh- variants if( !$this->mPreferredVariant ) { // see if some supported language variant is set in the // http header, but we don't set the mPreferredVariant // variable in case this is called before the user's // preference is loaded - $pv=$this->mMainLanguageCode; - if(array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { - $header = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])); - $zh = strstr($header, $pv.'-'); - if($zh) { - $ary = split("[,;]",$zh); - $pv = $ary[0]; + $preferredVariant = $this->mMainLanguageCode; + if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) { + $acceptLanguage = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])); + $languages = preg_split('/[,;]/', $acceptLanguage); + foreach( $languages as $language ) { + if( in_array( $language, $this->mVariants ) ) { + return $language; + break; + } } } - // don't try to return bad variant - if(in_array( $pv, $this->mVariants )) - return $pv; } return $this->mMainLanguageCode; @@ -870,6 +867,9 @@ class LanguageConverter { * @public */ function armourMath($text){ + // we need to convert '-{' and '}-' to '-{' and '}-' + // to avoid a unwanted '}-' appeared after the math-image. + $text = strtr( $text, array('-{' => '-{', '}-' => '}-') ); $ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end']; return $ret; } -- 2.20.1