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