Merge "Rewrite pref cleanup script"
[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 */
22
23 /**
24 * @ingroup Language
25 */
26 class GanConverter extends LanguageConverter {
27 /**
28 * @param Language $langobj
29 * @param string $maincode
30 * @param array $variants
31 * @param array $variantfallbacks
32 * @param array $flags
33 * @param array $manualLevel
34 */
35 function __construct( $langobj, $maincode,
36 $variants = [],
37 $variantfallbacks = [],
38 $flags = [],
39 $manualLevel = [] ) {
40 $this->mDescCodeSep = ':';
41 $this->mDescVarSep = ';';
42 parent::__construct( $langobj, $maincode,
43 $variants,
44 $variantfallbacks,
45 $flags,
46 $manualLevel );
47 $names = [
48 'gan' => '原文',
49 'gan-hans' => '简体',
50 'gan-hant' => '繁體',
51 ];
52 $this->mVariantNames = array_merge( $this->mVariantNames, $names );
53 }
54
55 function loadDefaultTables() {
56 $this->mTables = [
57 'gan-hans' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::$zh2Hans ),
58 'gan-hant' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::$zh2Hant ),
59 'gan' => new ReplacementArray
60 ];
61 }
62
63 /**
64 * @param string $key
65 * @return string
66 */
67 function convertCategoryKey( $key ) {
68 return $this->autoConvert( $key, 'gan' );
69 }
70 }
71
72 /**
73 * Gan Chinese
74 *
75 * class that handles both Traditional and Simplified Chinese
76 * right now it only distinguish gan_hans, gan_hant.
77 *
78 * @ingroup Language
79 */
80 class LanguageGan extends LanguageZh {
81 function __construct() {
82 parent::__construct();
83
84 $variants = [ 'gan', 'gan-hans', 'gan-hant' ];
85 $variantfallbacks = [
86 'gan' => [ 'gan-hans', 'gan-hant' ],
87 'gan-hans' => [ 'gan' ],
88 'gan-hant' => [ 'gan' ],
89 ];
90 $ml = [
91 'gan' => 'disable',
92 ];
93
94 $this->mConverter = new GanConverter( $this, 'gan',
95 $variants, $variantfallbacks,
96 [],
97 $ml );
98 }
99
100 /**
101 * word segmentation
102 *
103 * @param string $string
104 * @param string $autoVariant
105 * @return string
106 */
107 function normalizeForSearch( $string, $autoVariant = 'gan-hans' ) {
108 // LanguageZh::normalizeForSearch
109 return parent::normalizeForSearch( $string, $autoVariant );
110 }
111
112 }