Merge "Add pluggable talk page poster and use it for mediawiki.feedback"
[lhc/web/wiklou.git] / languages / classes / LanguageGan.php
1 <?php
2 /**
3 * Gan Chinese specific code.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Language
22 */
23
24 require_once __DIR__ . '/../LanguageConverter.php';
25 require_once __DIR__ . '/LanguageZh.php';
26
27 /**
28 * @ingroup Language
29 */
30 class GanConverter extends LanguageConverter {
31 /**
32 * @param Language $langobj
33 * @param string $maincode
34 * @param array $variants
35 * @param array $variantfallbacks
36 * @param array $flags
37 * @param array $manualLevel
38 */
39 function __construct( $langobj, $maincode,
40 $variants = array(),
41 $variantfallbacks = array(),
42 $flags = array(),
43 $manualLevel = array() ) {
44 $this->mDescCodeSep = ':';
45 $this->mDescVarSep = ';';
46 parent::__construct( $langobj, $maincode,
47 $variants,
48 $variantfallbacks,
49 $flags,
50 $manualLevel );
51 $names = array(
52 'gan' => '原文',
53 'gan-hans' => '简体',
54 'gan-hant' => '繁體',
55 );
56 $this->mVariantNames = array_merge( $this->mVariantNames, $names );
57 }
58
59 function loadDefaultTables() {
60 require __DIR__ . '/../../includes/ZhConversion.php';
61 $this->mTables = array(
62 'gan-hans' => new ReplacementArray( $zh2Hans ),
63 'gan-hant' => new ReplacementArray( $zh2Hant ),
64 'gan' => new ReplacementArray
65 );
66 }
67
68 /**
69 * @param string $key
70 * @return string
71 */
72 function convertCategoryKey( $key ) {
73 return $this->autoConvert( $key, 'gan' );
74 }
75 }
76
77 /**
78 * class that handles both Traditional and Simplified Chinese
79 * right now it only distinguish gan_hans, gan_hant.
80 *
81 * @ingroup Language
82 */
83 class LanguageGan extends LanguageZh {
84 function __construct() {
85 global $wgHooks;
86 parent::__construct();
87
88 $variants = array( 'gan', 'gan-hans', 'gan-hant' );
89 $variantfallbacks = array(
90 'gan' => array( 'gan-hans', 'gan-hant' ),
91 'gan-hans' => array( 'gan' ),
92 'gan-hant' => array( 'gan' ),
93 );
94 $ml = array(
95 'gan' => 'disable',
96 );
97
98 $this->mConverter = new GanConverter( $this, 'gan',
99 $variants, $variantfallbacks,
100 array(),
101 $ml );
102
103 $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
104 }
105
106 /**
107 * word segmentation
108 *
109 * @param string $string
110 * @param string $autoVariant
111 * @return string
112 */
113 function normalizeForSearch( $string, $autoVariant = 'gan-hans' ) {
114 // LanguageZh::normalizeForSearch
115 return parent::normalizeForSearch( $string, $autoVariant );
116 }
117
118 }