Minor tweaks to installer text
[mediawiki.git] / languages / classes / LanguageGan.php
blob0d652d43dec40db915d76454996fd44c55ef65a1
1 <?php
2 /**
3 * Gan Chinese specific code.
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.
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.
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
20 * @file
21 * @ingroup Language
24 require_once( __DIR__ . '/../LanguageConverter.php' );
25 require_once( __DIR__ . '/LanguageZh.php' );
27 /**
28 * @ingroup Language
30 class GanConverter extends LanguageConverter {
32 /**
33 * @param $langobj Language
34 * @param $maincode string
35 * @param $variants array
36 * @param $variantfallbacks array
37 * @param $flags array
38 * @param $manualLevel array
40 function __construct( $langobj, $maincode,
41 $variants = array(),
42 $variantfallbacks = array(),
43 $flags = array(),
44 $manualLevel = array() ) {
45 $this->mDescCodeSep = ':';
46 $this->mDescVarSep = ';';
47 parent::__construct( $langobj, $maincode,
48 $variants,
49 $variantfallbacks,
50 $flags,
51 $manualLevel );
52 $names = array(
53 'gan' => '原文',
54 'gan-hans' => '简体',
55 'gan-hant' => '繁體',
57 $this->mVariantNames = array_merge( $this->mVariantNames, $names );
60 function loadDefaultTables() {
61 require( __DIR__ . "/../../includes/ZhConversion.php" );
62 $this->mTables = array(
63 'gan-hans' => new ReplacementArray( $zh2Hans ),
64 'gan-hant' => new ReplacementArray( $zh2Hant ),
65 'gan' => new ReplacementArray
69 /**
70 * @param $key string
71 * @return String
73 function convertCategoryKey( $key ) {
74 return $this->autoConvert( $key, 'gan' );
78 /**
79 * class that handles both Traditional and Simplified Chinese
80 * right now it only distinguish gan_hans, gan_hant.
82 * @ingroup Language
84 class LanguageGan extends LanguageZh {
86 function __construct() {
87 global $wgHooks;
88 parent::__construct();
90 $variants = array( 'gan', 'gan-hans', 'gan-hant' );
91 $variantfallbacks = array(
92 'gan' => array( 'gan-hans', 'gan-hant' ),
93 'gan-hans' => array( 'gan' ),
94 'gan-hant' => array( 'gan' ),
96 $ml = array(
97 'gan' => 'disable',
100 $this->mConverter = new GanConverter( $this, 'gan',
101 $variants, $variantfallbacks,
102 array(),
103 $ml );
105 $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
109 * this should give much better diff info
111 * @param $text string
112 * @return string
114 function segmentForDiff( $text ) {
115 return preg_replace(
116 "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
117 "' ' .\"$1\"", $text );
121 * @param $text string
122 * @return string
124 function unsegmentForDiff( $text ) {
125 return preg_replace(
126 "/ ([\\xc0-\\xff][\\x80-\\xbf]*)/e",
127 "\"$1\"", $text );
131 * word segmentation
133 * @param $string string
134 * @param $autoVariant string
135 * @return String
137 function normalizeForSearch( $string, $autoVariant = 'gan-hans' ) {
138 // LanguageZh::normalizeForSearch
139 return parent::normalizeForSearch( $string, $autoVariant );
143 * @param $termsArray array
144 * @return array
146 function convertForSearchResult( $termsArray ) {
147 $terms = implode( '|', $termsArray );
148 $terms = self::convertDoubleWidth( $terms );
149 $terms = implode( '|', $this->mConverter->autoConvertToAllVariants( $terms ) );
150 $ret = array_unique( explode( '|', $terms ) );
151 return $ret;