3 require_once( dirname(__FILE__
).'/../LanguageConverter.php' );
4 require_once( dirname(__FILE__
).'/LanguageZh.php' );
9 class GanConverter
extends LanguageConverter
{
11 function __construct($langobj, $maincode,
13 $variantfallbacks=array(),
15 $manualLevel = array() ) {
16 $this->mDescCodeSep
= ':';
17 $this->mDescVarSep
= ';';
18 parent
::__construct($langobj, $maincode,
28 $this->mVariantNames
= array_merge($this->mVariantNames
,$names);
29 $this->loadNamespaceTables();
32 function loadNamespaceTables() {
33 global $wgMetaNamespace;
34 $nsproject = $wgMetaNamespace;
35 $projecttable = array(
36 'Wikipedia' => '维基百科',
37 'Wikisource' => '维基文库',
39 'Wiktionary' => '维基词典',
40 'Wikibooks' => '维基教科书',
41 'Wikiquote' => '维基语录',
43 $this->mNamespaceTables
['gan-hans'] = array(
48 'User talk' => '用户談詑',
50 => isset($projecttable[$nsproject]) ?
51 $projecttable[$nsproject] : $nsproject,
53 => isset($projecttable[$nsproject]) ?
54 $projecttable[$nsproject] . '談詑' : $nsproject . '談詑',
56 'File talk' => '文件談詑',
57 'MediaWiki' => 'MediaWiki',
58 'MediaWiki talk' => 'MediaWiki談詑',
60 'Template talk' => '模板談詑',
62 'Help talk' => '帮助談詑',
64 'Category talk' => '分类談詑',
66 $this->mNamespaceTables
['gan-hant'] = array_merge($this->mNamespaceTables
['gan-hans']);
67 $this->mNamespaceTables
['gan-hant']['File'] = '檔案';
68 $this->mNamespaceTables
['gan-hant']['File talk'] = '檔案談詑';
69 $this->mNamespaceTables
['gan'] = array_merge($this->mNamespaceTables
['gan-hans']);
72 function loadDefaultTables() {
73 require( dirname(__FILE__
)."/../../includes/ZhConversion.php" );
74 $this->mTables
= array(
75 'gan-hans' => new ReplacementArray( $zh2Hans ),
76 'gan-hant' => new ReplacementArray( $zh2Hant ),
77 'gan' => new ReplacementArray
81 /* there shouldn't be any latin text in Chinese conversion, so no need
83 $noParse is there for compatibility with LanguageConvert::markNoConversion
85 function markNoConversion($text, $noParse = false) {
89 function convertCategoryKey( $key ) {
90 return $this->autoConvert( $key, 'gan' );
95 * class that handles both Traditional and Simplified Chinese
96 * right now it only distinguish gan_hans, gan_hant.
100 class LanguageGan
extends LanguageZh
{
102 function __construct() {
104 parent
::__construct();
106 $variants = array('gan','gan-hans','gan-hant');
107 $variantfallbacks = array(
108 'gan' => array('gan-hans','gan-hant'),
109 'gan-hans' => array('gan'),
110 'gan-hant' => array('gan'),
116 $this->mConverter
= new GanConverter( $this, 'gan',
117 $variants, $variantfallbacks,
121 $wgHooks['ArticleSaveComplete'][] = $this->mConverter
;
124 # this should give much better diff info
125 function segmentForDiff( $text ) {
127 "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
128 "' ' .\"$1\"", $text);
131 function unsegmentForDiff( $text ) {
133 "/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e",
138 function normalizeForSearch( $string, $autoVariant = 'gan-hans' ) {
139 // LanguageZh::normalizeForSearch
140 return parent
::normalizeForSearch( $string, $autoVariant );
143 function convertForSearchResult( $termsArray ) {
144 $terms = implode( '|', $termsArray );
145 $terms = self
::convertDoubleWidth( $terms );
146 $terms = implode( '|', $this->mConverter
->autoConvertToAllVariants( $terms ) );
147 $ret = array_unique( explode('|', $terms) );