MediaWiki master
LanguageZh.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Languages;
8
33 public function segmentForDiff( $text ) {
34 $text = str_replace( "\x0c", "\u{FFFD}", $text );
35 return preg_replace( '/[\xc0-\xff][\x80-\xbf]*/', "\x0c$0", $text );
36 }
37
39 public function unsegmentForDiff( $text ) {
40 return str_replace( "\x0c", '', $text );
41 }
42
44 protected function getSearchIndexVariant() {
45 return 'zh-hans';
46 }
47
49 public function convertForSearchResult( $termsArray ) {
50 $terms = implode( '|', $termsArray );
51 $terms = self::convertDoubleWidth( $terms );
52 $terms = implode( '|', $this->getConverterInternal()->autoConvertToAllVariants( $terms ) );
53 return array_unique( explode( '|', $terms ) );
54 }
55}
56
58class_alias( LanguageZh::class, 'LanguageZh' );
getConverterInternal()
Return the LanguageConverter for this language, convenience function for use in the language classes ...
static convertDoubleWidth( $string)
Convert double-width roman characters to single-width.
Chinese-specific code.
segmentForDiff( $text)
Add a formfeed character between each non-ASCII character, so that "word-level" diffs will effectivel...
getSearchIndexVariant()
Specify the language variant that should be used for search indexing.string|null
convertForSearchResult( $termsArray)
string[]
unsegmentForDiff( $text)
And unsegment to show the result.string