3 require_once( dirname( __FILE__
) . '/../LanguageConverter.php' );
4 require_once( dirname( __FILE__
) . '/LanguageZh.php' );
9 class GanConverter
extends LanguageConverter
{
12 * @param $langobj Language
13 * @param $maincode string
14 * @param $variants array
15 * @param $variantfallbacks array
17 * @param $manualLevel array
19 function __construct( $langobj, $maincode,
21 $variantfallbacks = array(),
23 $manualLevel = array() ) {
24 $this->mDescCodeSep
= ':';
25 $this->mDescVarSep
= ';';
26 parent
::__construct( $langobj, $maincode,
36 $this->mVariantNames
= array_merge( $this->mVariantNames
, $names );
39 function loadDefaultTables() {
40 require( dirname( __FILE__
) . "/../../includes/ZhConversion.php" );
41 $this->mTables
= array(
42 'gan-hans' => new ReplacementArray( $zh2Hans ),
43 'gan-hant' => new ReplacementArray( $zh2Hant ),
44 'gan' => new ReplacementArray
49 * there shouldn't be any latin text in Chinese conversion, so no need
51 * $noParse is there for compatibility with LanguageConvert::markNoConversion
54 * @param $noParse bool
58 function markNoConversion( $text, $noParse = false ) {
66 function convertCategoryKey( $key ) {
67 return $this->autoConvert( $key, 'gan' );
72 * class that handles both Traditional and Simplified Chinese
73 * right now it only distinguish gan_hans, gan_hant.
77 class LanguageGan
extends LanguageZh
{
79 function __construct() {
81 parent
::__construct();
83 $variants = array( 'gan', 'gan-hans', 'gan-hant' );
84 $variantfallbacks = array(
85 'gan' => array( 'gan-hans', 'gan-hant' ),
86 'gan-hans' => array( 'gan' ),
87 'gan-hant' => array( 'gan' ),
93 $this->mConverter
= new GanConverter( $this, 'gan',
94 $variants, $variantfallbacks,
98 $wgHooks['ArticleSaveComplete'][] = $this->mConverter
;
102 * this should give much better diff info
104 * @param $text string
107 function segmentForDiff( $text ) {
109 "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
110 "' ' .\"$1\"", $text );
114 * @param $text string
117 function unsegmentForDiff( $text ) {
119 "/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e",
126 * @param $string string
127 * @param $autoVariant string
130 function normalizeForSearch( $string, $autoVariant = 'gan-hans' ) {
131 // LanguageZh::normalizeForSearch
132 return parent
::normalizeForSearch( $string, $autoVariant );
136 * @param $termsArray array
139 function convertForSearchResult( $termsArray ) {
140 $terms = implode( '|', $termsArray );
141 $terms = self
::convertDoubleWidth( $terms );
142 $terms = implode( '|', $this->mConverter
->autoConvertToAllVariants( $terms ) );
143 $ret = array_unique( explode( '|', $terms ) );