2009-03-23 19:10:28 +00:00
|
|
|
|
<?php
|
2012-06-06 20:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Gan Chinese specific code.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
*
|
|
|
|
|
|
* @file
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2009-03-23 19:10:28 +00:00
|
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
|
require_once __DIR__ . '/../LanguageConverter.php';
|
|
|
|
|
|
require_once __DIR__ . '/LanguageZh.php';
|
2009-03-23 19:10:28 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
|
|
|
|
|
class GanConverter extends LanguageConverter {
|
|
|
|
|
|
|
2011-05-29 16:32:05 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @param $langobj Language
|
|
|
|
|
|
* @param $maincode string
|
|
|
|
|
|
* @param $variants array
|
|
|
|
|
|
* @param $variantfallbacks array
|
|
|
|
|
|
* @param $flags array
|
|
|
|
|
|
* @param $manualLevel array
|
|
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function __construct( $langobj, $maincode,
|
|
|
|
|
|
$variants = array(),
|
|
|
|
|
|
$variantfallbacks = array(),
|
2009-03-23 19:10:28 +00:00
|
|
|
|
$flags = array(),
|
|
|
|
|
|
$manualLevel = array() ) {
|
|
|
|
|
|
$this->mDescCodeSep = ':';
|
|
|
|
|
|
$this->mDescVarSep = ';';
|
2010-07-29 09:43:18 +00:00
|
|
|
|
parent::__construct( $langobj, $maincode,
|
2009-03-23 19:10:28 +00:00
|
|
|
|
$variants,
|
|
|
|
|
|
$variantfallbacks,
|
|
|
|
|
|
$flags,
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$manualLevel );
|
2009-03-23 19:10:28 +00:00
|
|
|
|
$names = array(
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'gan' => '原文',
|
2009-03-23 19:10:28 +00:00
|
|
|
|
'gan-hans' => '简体',
|
|
|
|
|
|
'gan-hant' => '繁體',
|
|
|
|
|
|
);
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$this->mVariantNames = array_merge( $this->mVariantNames, $names );
|
2009-03-23 19:10:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadDefaultTables() {
|
2013-05-17 00:16:59 +00:00
|
|
|
|
require __DIR__ . '/../../includes/ZhConversion.php';
|
2009-03-23 19:10:28 +00:00
|
|
|
|
$this->mTables = array(
|
|
|
|
|
|
'gan-hans' => new ReplacementArray( $zh2Hans ),
|
|
|
|
|
|
'gan-hant' => new ReplacementArray( $zh2Hant ),
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'gan' => new ReplacementArray
|
2009-03-23 19:10:28 +00:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-29 16:32:05 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @param $key string
|
|
|
|
|
|
* @return String
|
|
|
|
|
|
*/
|
2009-03-23 19:10:28 +00:00
|
|
|
|
function convertCategoryKey( $key ) {
|
|
|
|
|
|
return $this->autoConvert( $key, 'gan' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* class that handles both Traditional and Simplified Chinese
|
|
|
|
|
|
* right now it only distinguish gan_hans, gan_hant.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
|
|
|
|
|
class LanguageGan extends LanguageZh {
|
|
|
|
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
|
|
global $wgHooks;
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$variants = array( 'gan', 'gan-hans', 'gan-hant' );
|
2009-03-23 19:10:28 +00:00
|
|
|
|
$variantfallbacks = array(
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'gan' => array( 'gan-hans', 'gan-hant' ),
|
2010-07-29 09:43:18 +00:00
|
|
|
|
'gan-hans' => array( 'gan' ),
|
|
|
|
|
|
'gan-hant' => array( 'gan' ),
|
2009-03-23 19:10:28 +00:00
|
|
|
|
);
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$ml = array(
|
2013-04-17 19:10:02 +00:00
|
|
|
|
'gan' => 'disable',
|
2009-03-23 19:10:28 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$this->mConverter = new GanConverter( $this, 'gan',
|
|
|
|
|
|
$variants, $variantfallbacks,
|
2010-01-19 02:36:33 +00:00
|
|
|
|
array(),
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$ml );
|
2009-03-23 19:10:28 +00:00
|
|
|
|
|
2012-10-11 16:22:52 +00:00
|
|
|
|
$wgHooks['PageContentSaveComplete'][] = $this->mConverter;
|
2009-03-23 19:10:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-29 16:32:05 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* word segmentation
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param $string string
|
|
|
|
|
|
* @param $autoVariant string
|
|
|
|
|
|
* @return String
|
|
|
|
|
|
*/
|
2010-02-02 15:09:01 +00:00
|
|
|
|
function normalizeForSearch( $string, $autoVariant = 'gan-hans' ) {
|
|
|
|
|
|
// LanguageZh::normalizeForSearch
|
|
|
|
|
|
return parent::normalizeForSearch( $string, $autoVariant );
|
2009-03-23 19:10:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2010-01-19 02:36:33 +00:00
|
|
|
|
}
|