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 }
Simplified Chinese.
Chinese-specific code.
Definition: LanguageZh.php:30
convertForSearchResult( $termsArray)
Definition: LanguageZh.php:71
segmentForDiff( $text)
this should give much better diff info
Definition: LanguageZh.php:37
unsegmentForDiff( $text)
Definition: LanguageZh.php:45
normalizeForSearch( $string, $autoVariant='zh-hans')
auto convert to zh-hans and normalize special characters.
Definition: LanguageZh.php:56
static convertDoubleWidth( $string)
convert double-width roman characters to single-width.
Definition: Language.php:2888
autoConvertToAllVariants( $text)
convert text to all supported variants
Definition: Language.php:4187
getConverter()
Return the LanguageConverter used in the Language.
Definition: Language.php:4161
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s