}
/**
- * @access public
+ * @public
*/
function getVariants() {
return $this->mVariants;
* get preferred language variants.
* @param boolean $fromUser Get it from $wgUser's preferences
* @return string the preferred language code
- * @access public
+ * @public
*/
function getPreferredVariant( $fromUser = true ) {
global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant;
}
/**
- * @access private
+ * @private
*/
function applyManualConv($convRule,$variant){
if(!$variant) $variant = $this->getPreferredVariant();
// use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
if($is_title_flag){
$this->mTitleFromFlag = true;
- $this->mTitleDisplay = $convRule->getRulesTitle();
+ $this->mTitleDisplay = $convRule->getTitle();
}
if($this->mManualLevel[$variant]=='disable') return;
* @param string $text text to be converted
* @param bool $isTitle whether this conversion is for the article title
* @return string converted text
- * @access public
+ * @public
*/
function convert( $text , $isTitle=false) {
$this->mVariantNames,
$this->mDoContentConvert,
$this->mDoTitleConvert);
- $crule->parseRules($plang,
+ $crule->parse($plang,
$this->getVariantFallbacks($plang),
$this->mManualLevel[$plang]=='disable');
- $text .= $crule->getRulesDisplay();
+ $text .= $crule->getDisplay();
$this->applyManualConv($crule,$plang);
if(array_key_exists(1, $marked)){
* @param string $link the name of the link
* @param mixed $nt the title object of the link
* @return null the input parameters may be modified upon return
- * @access public
+ * @public
*/
function findVariantLink( &$link, &$nt ) {
global $wgDisableLangConversion;
/**
* returns language specific hash options
*
- * @access public
+ * @public
*/
function getExtraHashOptions() {
$variant = $this->getPreferredVariant();
/**
* get title text as defined in the body of the article text
*
- * @access public
+ * @public
*/
function getParsedTitle() {
return $this->mTitleDisplay;
}
/**
+ * parser for rules of language conversion , parse rules in -{ }- tag
* @ingroup Language
* @author fdcn <fdcn64@gmail.com>
*/
* @private
*/
function parseFlags(){
- $flags = array();
$text = $this->mText;
-
- // for multi-FLAGs
if(strlen($text) < 2 ) {
$this->flags = array( 'R' );
$this->rules = $text;
return;
}
+ $flags = array();
$tt = explode($this->mMarkup['flagsep'], $text, 2);
if(count($tt) == 2) {
return $this->rules;
}
}
+
/**
* Parse rules and flags
* @public
*/
- function parseRules($variant,$variantFallbacks,$isMCDisable=false){
+ function parse($variant,$variantFallbacks,$isMCDisable=false){
$this->parseFlags();
$this->generateConvTable();
if(count($this->bidtable)==0 && count($this->unidtable)==0
&& !in_array('N',$flags) && !in_array('T',$flags) )
{
- $flags = array('R');
+ $this->flags = $flags = array('R');
}
if( in_array('R',$flags) ) {
* @param string $variant the current variant
* @public
*/
- function getRulesDisplay(){
+ function getDisplay(){
return $this->ruleDisplay;
}
/**
* @param string $variant the current variant
* @public
*/
- function getRulesTitle(){
+ function getTitle(){
return $this->ruleTitle;
}
$fallback = 'zh-hans';
+$namespaceAliases = array(
+ '媒体' => NS_MEDIA,
+ '媒體' => NS_MEDIA,
+ '特殊' => NS_SPECIAL,
+ '对话' => NS_TALK,
+ '對話' => NS_TALK,
+ '讨论' => NS_TALK,
+ '討論' => NS_TALK,
+ '用户' => NS_USER,
+ '用戶' => NS_USER,
+ '用户对话' => NS_USER_TALK,
+ '用戶對話' => NS_USER_TALK,
+ '用户讨论' => NS_USER_TALK,
+ '用戶討論' => NS_USER_TALK,
+ # This has never worked so it's unlikely to annoy anyone if I disable it -- TS
+ #'{{SITENAME}}_对话' => NS_PROJECT_TALK
+ #"{{SITENAME}}_對話" => NS_PROJECT_TALK
+ '图像' => NS_IMAGE,
+ '圖像' => NS_IMAGE,
+ '图像对话' => NS_IMAGE_TALK,
+ '圖像對話' => NS_IMAGE_TALK,
+ '模板' => NS_TEMPLATE,
+ '模板讨论'=> NS_TEMPLATE_TALK,
+ "樣板" => NS_TEMPLATE,
+ "樣板討論" => NS_TEMPLATE_TALK,
+ '帮助' => NS_HELP,
+ '帮助讨论'=> NS_HELP_TALK,
+ "幫助" => NS_HELP,
+ "幫助討論" => NS_HELP_TALK,
+ '分类' => NS_CATEGORY,
+ '分类讨论'=> NS_CATEGORY_TALK,
+ "分類" => NS_CATEGORY,
+ "分類討論" => NS_CATEGORY_TALK,
+);
+
$messages = array(
/*
Short names for language variants used for language conversion links.