MediaWiki  master
LanguageZh.php
Go to the documentation of this file.
1 <?php
30 class LanguageZh extends LanguageZh_hans {
37  public function segmentForDiff( $text ) {
38  return preg_replace( '/[\xc0-\xff][\x80-\xbf]*/', ' $0', $text );
39  }
40 
45  public function unsegmentForDiff( $text ) {
46  return preg_replace( '/ ([\xc0-\xff][\x80-\xbf]*)/', '$1', $text );
47  }
48 
56  public function normalizeForSearch( $string, $autoVariant = 'zh-hans' ) {
57  // always convert to zh-hans before indexing. it should be
58  // better to use zh-hans for search, since conversion from
59  // Traditional to Simplified is less ambiguous than the
60  // other way around
61  $s = $this->getConverter()->autoConvert( $string, $autoVariant );
62  // LanguageZh_hans::normalizeForSearch
63  $s = parent::normalizeForSearch( $s );
64  return $s;
65  }
66 
71  public function convertForSearchResult( $termsArray ) {
72  $terms = implode( '|', $termsArray );
73  $terms = self::convertDoubleWidth( $terms );
74  $terms = implode( '|', $this->getConverter()->autoConvertToAllVariants( $terms ) );
75  $ret = array_unique( explode( '|', $terms ) );
76  return $ret;
77  }
78 }
LanguageZh
class that handles both Traditional and Simplified Chinese right now it only distinguish zh_hans,...
Definition: LanguageZh.php:30
Language\getConverter
getConverter()
Return the LanguageConverter used in the Language.
Definition: Language.php:4117
$s
$s
Definition: mergeMessageFileList.php:185
LanguageZh\convertForSearchResult
convertForSearchResult( $termsArray)
Definition: LanguageZh.php:71
LanguageZh\unsegmentForDiff
unsegmentForDiff( $text)
Definition: LanguageZh.php:45
LanguageZh\segmentForDiff
segmentForDiff( $text)
this should give much better diff info
Definition: LanguageZh.php:37
Language\convertDoubleWidth
static convertDoubleWidth( $string)
convert double-width roman characters to single-width.
Definition: Language.php:2914
LanguageZh_hans
Simplified Chinese.
Definition: LanguageZh_hans.php:30
LanguageZh\normalizeForSearch
normalizeForSearch( $string, $autoVariant='zh-hans')
auto convert to zh-hans and normalize special characters.
Definition: LanguageZh.php:56
Language\autoConvertToAllVariants
autoConvertToAllVariants( $text)
convert text to all supported variants
Definition: Language.php:4143