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