| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
class ZhConverter extends LanguageConverter { |
| 27 |
|
| 28 |
public function getMainCode(): string { |
| 29 |
return 'zh'; |
| 30 |
} |
| 31 |
|
| 32 |
public function getLanguageVariants(): array { |
| 33 |
return [ |
| 34 |
'zh', |
| 35 |
'zh-hans', |
| 36 |
'zh-hant', |
| 37 |
'zh-cn', |
| 38 |
'zh-hk', |
| 39 |
'zh-mo', |
| 40 |
'zh-my', |
| 41 |
'zh-sg', |
| 42 |
'zh-tw' |
| 43 |
]; |
| 44 |
} |
| 45 |
|
| 46 |
public function getVariantsFallbacks(): array { |
| 47 |
return [ |
| 48 |
'zh' => [ |
| 49 |
'zh-hans', |
| 50 |
'zh-hant', |
| 51 |
'zh-cn', |
| 52 |
'zh-tw', |
| 53 |
'zh-hk', |
| 54 |
'zh-sg', |
| 55 |
'zh-mo', |
| 56 |
'zh-my' |
| 57 |
], |
| 58 |
'zh-hans' => [ 'zh-cn', 'zh-sg', 'zh-my' ], |
| 59 |
'zh-hant' => [ 'zh-tw', 'zh-hk', 'zh-mo' ], |
| 60 |
'zh-cn' => [ 'zh-hans', 'zh-sg', 'zh-my' ], |
| 61 |
'zh-sg' => [ 'zh-my', 'zh-hans', 'zh-cn' ], |
| 62 |
'zh-my' => [ 'zh-sg', 'zh-hans', 'zh-cn' ], |
| 63 |
'zh-tw' => [ 'zh-hant', 'zh-hk', 'zh-mo' ], |
| 64 |
'zh-hk' => [ 'zh-mo', 'zh-hant', 'zh-tw' ], |
| 65 |
'zh-mo' => [ 'zh-hk', 'zh-hant', 'zh-tw' ], |
| 66 |
]; |
| 67 |
} |
| 68 |
|
| 69 |
public function getAdditionalManualLevel(): array { |
| 70 |
return [ |
| 71 |
'zh' => 'disable', |
| 72 |
'zh-hans' => 'unidirectional', |
| 73 |
'zh-hant' => 'unidirectional', |
| 74 |
]; |
| 75 |
} |
| 76 |
|
| 77 |
public function getDescCodeSeparator(): string { |
| 78 |
return ':'; |
| 79 |
} |
| 80 |
|
| 81 |
public function getDescVarSeparator(): string { |
| 82 |
return ';'; |
| 83 |
} |
| 84 |
|
| 85 |
public function getVariantNames(): array { |
| 86 |
$names = [ |
| 87 |
'zh' => '原文', |
| 88 |
'zh-hans' => '简体', |
| 89 |
'zh-hant' => '繁體', |
| 90 |
'zh-cn' => '大陆', |
| 91 |
'zh-tw' => '臺灣', |
| 92 |
'zh-hk' => '香港', |
| 93 |
'zh-mo' => '澳門', |
| 94 |
'zh-sg' => '新加坡', |
| 95 |
'zh-my' => '大马', |
| 96 |
]; |
| 97 |
return array_merge( parent::getVariantNames(), $names ); |
| 98 |
} |
| 99 |
|
| 100 |
protected function loadDefaultTables(): array { |
| 101 |
return [ |
| 102 |
'zh-hans' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_HANS ), |
| 103 |
'zh-hant' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_HANT ), |
| 104 |
'zh-cn' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_CN ), |
| 105 |
'zh-hk' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_HK ), |
| 106 |
'zh-mo' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_HK ), |
| 107 |
'zh-my' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_CN ), |
| 108 |
'zh-sg' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_CN ), |
| 109 |
'zh-tw' => new ReplacementArray( MediaWiki\Languages\Data\ZhConversion::ZH_TO_TW ), |
| 110 |
'zh' => new ReplacementArray |
| 111 |
]; |
| 112 |
} |
| 113 |
|
| 114 |
protected function postLoadTables( &$tables ) { |
| 115 |
$tables['zh-cn']->setArray( |
| 116 |
$tables['zh-cn']->getArray() + $tables['zh-hans']->getArray() |
| 117 |
); |
| 118 |
$tables['zh-hk']->setArray( |
| 119 |
$tables['zh-hk']->getArray() + $tables['zh-hant']->getArray() |
| 120 |
); |
| 121 |
$tables['zh-mo']->setArray( |
| 122 |
$tables['zh-mo']->getArray() + $tables['zh-hant']->getArray() |
| 123 |
); |
| 124 |
$tables['zh-my']->setArray( |
| 125 |
$tables['zh-my']->getArray() + $tables['zh-hans']->getArray() |
| 126 |
); |
| 127 |
$tables['zh-sg']->setArray( |
| 128 |
$tables['zh-sg']->getArray() + $tables['zh-hans']->getArray() |
| 129 |
); |
| 130 |
$tables['zh-tw']->setArray( |
| 131 |
$tables['zh-tw']->getArray() + $tables['zh-hant']->getArray() |
| 132 |
); |
| 133 |
} |
| 134 |
|
| 135 |
public function convertCategoryKey( $key ) { |
| 136 |
return $this->autoConvert( $key, 'zh' ); |
| 137 |
} |
| 138 |
} |