MediaWiki
REL1_22
|
00001 <?php 00024 require_once __DIR__ . '/../LanguageConverter.php'; 00025 00038 class IuConverter extends LanguageConverter { 00039 00040 protected $mDoContentConvert; 00041 public $mToLatin = array( 00042 'ᐦ' => 'h', 'ᐃ' => 'i', 'ᐄ' => 'ii', 'ᐅ' => 'u', 'ᐆ' => 'uu', 'ᐊ' => 'a', 'ᐋ' => 'aa', 00043 'ᑉ' => 'p', 'ᐱ' => 'pi', 'ᐲ' => 'pii', 'ᐳ' => 'pu', 'ᐴ' => 'puu', 'ᐸ' => 'pa', 'ᐹ' => 'paa', 00044 'ᑦ' => 't', 'ᑎ' => 'ti', 'ᑏ' => 'tii', 'ᑐ' => 'tu', 'ᑑ' => 'tuu', 'ᑕ' => 'ta', 'ᑖ' => 'taa', 00045 'ᒃ' => 'k', 'ᑭ' => 'ki', 'ᑮ' => 'kii', 'ᑯ' => 'ku', 'ᑰ' => 'kuu', 'ᑲ' => 'ka', 'ᑳ' => 'kaa', 00046 'ᖅᒃ' => 'qq', 'ᖅᑭ' => 'qqi', 'ᖅᑮ' => 'qqii', 'ᖅᑯ' => 'qqu', 'ᖅᑰ' => 'ᖅqquu', 'ᖅᑲ' => 'qqa', 'ᖅᑳ' => 'qqaa', 00047 'ᒡ' => 'g', 'ᒋ' => 'gi', 'ᒌ' => 'gii', 'ᒍ' => 'gu', 'ᒎ' => 'guu', 'ᒐ' => 'ga', 'ᒑ' => 'gaa', 00048 'ᒻ' => 'm', 'ᒥ' => 'mi', 'ᒦ' => 'mii', 'ᒧ' => 'mu', 'ᒨ' => 'muu', 'ᒪ' => 'ma', 'ᒫ' => 'maa', 00049 'ᓐ' => 'n', 'ᓂ' => 'ni', 'ᓃ' => 'nii', 'ᓄ' => 'nu', 'ᓅ' => 'nuu', 'ᓇ' => 'na', 'ᓈ' => 'naa', 00050 'ᔅ' => 's', 'ᓯ' => 'si', 'ᓰ' => 'sii', 'ᓱ' => 'su', 'ᓲ' => 'suu', 'ᓴ' => 'sa', 'ᓵ' => 'saa', 00051 'ᓪ' => 'l', 'ᓕ' => 'li', 'ᓖ' => 'lii', 'ᓗ' => 'lu', 'ᓘ' => 'luu', 'ᓚ' => 'la', 'ᓛ' => 'laa', 00052 'ᔾ' => 'j', 'ᔨ' => 'ji', 'ᔩ' => 'jii', 'ᔪ' => 'ju', 'ᔫ' => 'juu', 'ᔭ' => 'ja', 'ᔮ' => 'jaa', 00053 'ᕝ' => 'v', 'ᕕ' => 'vi', 'ᕖ' => 'vii', 'ᕗ' => 'vu', 'ᕘ' => 'vuu', 'ᕙ' => 'va', 'ᕚ' => 'vaa', 00054 'ᕐ' => 'r', 'ᕆ' => 'ri', 'ᕇ' => 'rii', 'ᕈ' => 'ru', 'ᕉ' => 'ruu', 'ᕋ' => 'ra', 'ᕌ' => 'raa', 00055 'ᖅ' => 'q', 'ᕿ' => 'qi', 'ᖀ' => 'qii', 'ᖁ' => 'qu', 'ᖂ' => 'quu', 'ᖃ' => 'qa', 'ᖄ' => 'qaa', 00056 'ᖕ' => 'ng', 'ᖏ' => 'ngi', 'ᖐ' => 'ngii', 'ᖑ' => 'ngu', 'ᖒ' => 'nguu', 'ᖓ' => 'nga', 'ᖔ' => 'ngaa', 00057 'ᖖ' => 'nng', 'ᙱ' => 'nngi', 'ᙲ' => 'nngii', 'ᙳ' => 'nngu', 'ᙴ' => 'nnguu', 'ᙵ' => 'nnga', 'ᙶ' => 'nngaa', 00058 'ᖦ' => 'ɫ', 'ᖠ' => 'ɫi', 'ᖡ' => 'ɫii', 'ᖢ' => 'ɫu', 'ᖣ' => 'ɫuu', 'ᖤ' => 'ɫa', 'ᖥ' => 'ɫaa', 00059 ); 00060 00061 public $mUpperToLowerCaseLatin = array( 00062 'A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e', 00063 'F' => 'f', 'G' => 'g', 'H' => 'h', 'I' => 'i', 'J' => 'j', 00064 'K' => 'k', 'L' => 'l', 'M' => 'm', 'N' => 'n', 'O' => 'o', 00065 'P' => 'p', 'Q' => 'q', 'R' => 'r', 'S' => 's', 'T' => 't', 00066 'U' => 'u', 'V' => 'v', 'W' => 'w', 'X' => 'x', 'Y' => 'y', 00067 'Z' => 'z', 00068 ); 00069 00070 public $mToSyllabics = array( 00071 'h' => 'ᐦ', 'i' => 'ᐃ', 'ii' => 'ᐄ', 'u' => 'ᐅ', 'uu' => 'ᐆ', 'a' => 'ᐊ', 'aa' => 'ᐋ', 00072 'p' => 'ᑉ', 'pi' => 'ᐱ', 'pii' => 'ᐲ', 'pu' => 'ᐳ', 'puu' => 'ᐴ', 'pa' => 'ᐸ', 'paa' => 'ᐹ', 00073 't' => 'ᑦ', 'ti' => 'ᑎ', 'tii' => 'ᑏ', 'tu' => 'ᑐ', 'tuu' => 'ᑑ', 'ta' => 'ᑕ', 'taa' => 'ᑖ', 00074 'k' => 'ᒃ', 'ki' => 'ᑭ', 'kii' => 'ᑮ', 'ku' => 'ᑯ', 'kuu' => 'ᑰ', 'ka' => 'ᑲ', 'kaa' => 'ᑳ', 00075 'g' => 'ᒡ', 'gi' => 'ᒋ', 'gii' => 'ᒌ', 'gu' => 'ᒍ', 'guu' => 'ᒎ', 'ga' => 'ᒐ', 'gaa' => 'ᒑ', 00076 'm' => 'ᒻ', 'mi' => 'ᒥ', 'mii' => 'ᒦ', 'mu' => 'ᒧ', 'muu' => 'ᒨ', 'ma' => 'ᒪ', 'maa' => 'ᒫ', 00077 'n' => 'ᓐ', 'ni' => 'ᓂ', 'nii' => 'ᓃ', 'nu' => 'ᓄ', 'nuu' => 'ᓅ', 'na' => 'ᓇ', 'naa' => 'ᓈ', 00078 's' => 'ᔅ', 'si' => 'ᓯ', 'sii' => 'ᓰ', 'su' => 'ᓱ', 'suu' => 'ᓲ', 'sa' => 'ᓴ', 'saa' => 'ᓵ', 00079 'l' => 'ᓪ', 'li' => 'ᓕ', 'lii' => 'ᓖ', 'lu' => 'ᓗ', 'luu' => 'ᓘ', 'la' => 'ᓚ', 'laa' => 'ᓛ', 00080 'j' => 'ᔾ', 'ji' => 'ᔨ', 'jii' => 'ᔩ', 'ju' => 'ᔪ', 'juu' => 'ᔫ', 'ja' => 'ᔭ', 'jaa' => 'ᔮ', 00081 'v' => 'ᕝ', 'vi' => 'ᕕ', 'vii' => 'ᕖ', 'vu' => 'ᕗ', 'vuu' => 'ᕘ', 'va' => 'ᕙ', 'vaa' => 'ᕚ', 00082 'r' => 'ᕐ', 'ri' => 'ᕆ', 'rii' => 'ᕇ', 'ru' => 'ᕈ', 'ruu' => 'ᕉ', 'ra' => 'ᕋ', 'raa' => 'ᕌ', 00083 'qq' => 'ᖅᒃ', 'qqi' => 'ᖅᑭ', 'qqii' => 'ᖅᑮ', 'qqu' => 'ᖅᑯ', 'qquu' => 'ᖅᑰ', 'qqa' => 'ᖅᑲ', 'qqaa' => 'ᖅᑳ', 00084 'q' => 'ᖅ', 'qi' => 'ᕿ', 'qii' => 'ᖀ', 'qu' => 'ᖁ', 'quu' => 'ᖂ', 'qa' => 'ᖃ', 'qaa' => 'ᖄ', 00085 'ng' => 'ᖕ', 'ngi' => 'ᖏ', 'ngii' => 'ᖐ', 'ngu' => 'ᖑ', 'nguu' => 'ᖒ', 'nga' => 'ᖓ', 'ngaa' => 'ᖔ', 00086 'nng' => 'ᖖ', 'nngi' => 'ᙱ', 'nngii' => 'ᙲ', 'nngu' => 'ᙳ', 'nnguu' => 'ᙴ', 'nnga' => 'ᙵ', 'nngaa' => 'ᙶ', 00087 'ɫ' => 'ᖦ', 'ɫi' => 'ᖠ', 'ɫii' => 'ᖡ', 'ɫu' => 'ᖢ', 'ɫuu' => 'ᖣ', 'ɫa' => 'ᖤ', 'ɫaa' => 'ᖥ', 00088 ); 00089 00090 function loadDefaultTables() { 00091 $this->mTables = array( 00092 'lowercase' => new ReplacementArray( $this->mUpperToLowerCaseLatin ), 00093 'ike-cans' => new ReplacementArray( $this->mToSyllabics ), 00094 'ike-latn' => new ReplacementArray( $this->mToLatin ), 00095 'iu' => new ReplacementArray() 00096 ); 00097 } 00098 00109 function parseManualRule( $rule, $flags = array() ) { 00110 if ( in_array( 'T', $flags ) ) { 00111 return parent::parseManualRule( $rule, $flags ); 00112 } 00113 00114 $carray = array(); 00115 // otherwise ignore all formatting 00116 foreach ( $this->mVariants as $v ) { 00117 $carray[$v] = $rule; 00118 } 00119 00120 return $carray; 00121 } 00122 00130 function parserConvert( $text, &$parser ) { 00131 $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() ); 00132 00133 return parent::parserConvert( $text, $parser ); 00134 } 00135 00146 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) { 00147 // check for user namespace 00148 if ( is_object( $nt ) ) { 00149 $ns = $nt->getNamespace(); 00150 if ( $ns == NS_USER || $ns == NS_USER_TALK ) { 00151 return; 00152 } 00153 } 00154 00155 $oldlink = $link; 00156 parent::findVariantLink( $link, $nt, $ignoreOtherCond ); 00157 if ( $this->getPreferredVariant() == $this->mMainLanguageCode ) { 00158 $link = $oldlink; 00159 } 00160 } 00161 00171 function autoConvert( $text, $toVariant = false ) { 00172 global $wgTitle; 00173 if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) { 00174 $imagename = $wgTitle->getNsText(); 00175 if ( preg_match( "/^$imagename:/", $text ) ) { 00176 return $text; 00177 } 00178 } 00179 return parent::autoConvert( $text, $toVariant ); 00180 } 00181 00190 function translate( $text, $toVariant ) { 00191 // If $text is empty or only includes spaces, do nothing 00192 // Otherwise translate it 00193 if ( trim( $text ) ) { 00194 $this->loadTables(); 00195 // To syllabics, first translate uppercase to lowercase Latin 00196 if ( $toVariant == 'ike-cans' ) { 00197 $text = $this->mTables['lowercase']->replace( $text ); 00198 } 00199 $text = $this->mTables[$toVariant]->replace( $text ); 00200 } 00201 return $text; 00202 } 00203 } 00204 00210 class LanguageIu extends Language { 00211 function __construct() { 00212 global $wgHooks; 00213 00214 parent::__construct(); 00215 00216 $variants = array( 'iu', 'ike-cans', 'ike-latn' ); 00217 $variantfallbacks = array( 00218 'iu' => 'ike-cans', 00219 'ike-cans' => 'iu', 00220 'ike-latn' => 'iu', 00221 ); 00222 00223 $flags = array(); 00224 $this->mConverter = new IuConverter( $this, 'iu', $variants, $variantfallbacks, $flags ); 00225 $wgHooks['PageContentSaveComplete'][] = $this->mConverter; 00226 } 00227 }