MediaWiki  REL1_19
LanguageKu.php
Go to the documentation of this file.
00001 <?php
00002 require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
00003 require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
00004 
00010 class KuConverter extends LanguageConverter {
00011         var $mArabicToLatin = array(
00012                 'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
00013                 'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
00014                 'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
00015                 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
00016 
00017 // ک و => ku -- ist richtig
00018 //  و ك=> ku -- ist auch richtig
00019 
00020                 /* Doppel- und Halbvokale */
00021                 'ڵ' => 'll', # ll
00022                 'ڕ'  => 'rr', # rr
00023                 'ا'  => 'a',
00024                 # 'ئێ' => 'ê', # initial e
00025                 'ە'  => 'e',
00026                 'ه‌'  => 'e', # with one non-joiner
00027                 'ه‌‌'  => 'e', # with two non-joiner
00028                 'ة'  => 'e',
00029                 'ێ' => 'ê',
00030                 'ي'  => 'î',
00031                 'ی'  => 'î', # U+06CC  db 8c  ARABIC LETTER FARSI YEH
00032                 'ى'  => 'î', # U+0649  d9 89  ARABIC LETTER ALEF MAKSURA
00033                 'ۆ'  => 'o',
00034                 'و'  => 'w',
00035                 'ئ'  => '', # initial hemze should not be shown
00036                 '،'  => ',',
00037                 'ع'  => '\'', # ayn
00038                 '؟'  => '?',
00039 
00040                 # digits
00041                 '٠' => '0', # &#x0660;
00042                 '١' => '1', # &#x0661;
00043                 '٢' => '2', # &#x0662;
00044                 '٣' => '3', # &#x0663;
00045                 '٤' => '4', # &#x0664;
00046                 '٥' => '5', # &#x0665;
00047                 '٦' => '6', # &#x0666;
00048                 '٧' => '7', # &#x0667;
00049                 '٨' => '8', # &#x0668;
00050                 '٩' => '9', # &#x0669;
00051         );
00052 
00053         var $mLatinToArabic = array(
00054                 'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
00055                 'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
00056                 'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
00057                 't' => 'ت', 'v' => 'ڤ',
00058                 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
00059 
00060 
00061                 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
00062                 'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
00063                 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
00064                 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
00065                 'Y' => 'ی', 'Z' => 'ز',
00066 
00067                 /* Doppelkonsonanten */
00068                 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
00069                 # 'rr' => 'ڕ', # selbiges für doppel-r
00070 
00071                 /* Einzelne Großbuchstaben */
00072                 // ' C' => 'ج',
00073 
00074                 /* Vowels */
00075                 'a' => 'ا',
00076                 'e' => 'ە',
00077                 'ê' => 'ێ',
00078                 'i' => '',
00079                 'î' => 'ی',
00080                 'o' => 'ۆ',
00081                 'u' => 'و',
00082                 'û' => 'وو',
00083                 'w' => 'و',
00084                 ',' => '،',
00085                 '?' => '؟',
00086 
00087                 # Try to replace the leading vowel
00088                 ' a' => 'ئا ',
00089                 ' e' => 'ئە ',
00090                 ' ê' => 'ئێ ',
00091                 ' î' => 'ئی ',
00092                 ' o' => 'ئۆ ',
00093                 ' u' => 'ئو ',
00094                 ' û' => 'ئوو ',
00095                 'A'  => 'ئا',
00096                 'E'  => 'ئە',
00097                 'Ê'  => 'ئێ',
00098                 'Î'  => 'ئی',
00099                 'O'  => 'ئۆ',
00100                 'U'  => 'ئو',
00101                 'Û'  => 'ئوو',
00102                 ' A' => 'ئا ',
00103                 ' E' => 'ئە ',
00104                 ' Ê' => 'ئێ ',
00105                 ' Î' => 'ئی ',
00106                 ' O' => 'ئۆ ',
00107                 ' U' => 'ئو ',
00108                 ' Û' => 'ئوو ',
00109                 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
00110                 # '\'' => 'ع',
00111 
00112 /*              # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
00113                 # digits
00114                 '0' => '٠', # &#x0660;
00115                 '1' => '١', # &#x0661;
00116                 '2' => '٢', # &#x0662;
00117                 '3' => '٣', # &#x0663;
00118                 '4' => '٤', # &#x0664;
00119                 '5' => '٥', # &#x0665;
00120                 '6' => '٦', # &#x0666;
00121                 '7' => '٧', # &#x0667;
00122                 '8' => '٨', # &#x0668;
00123                 '9' => '٩', # &#x0669;
00124 */
00125                 );
00126 
00127         function loadDefaultTables() {
00128                 $this->mTables = array(
00129                         'ku-latn' => new ReplacementArray( $this->mArabicToLatin ),
00130                         'ku-arab' => new ReplacementArray( $this->mLatinToArabic ),
00131                         'ku'      => new ReplacementArray()
00132                 );
00133         }
00134 
00145         function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
00146                 // check for user namespace
00147                 if ( is_object( $nt ) ) {
00148                         $ns = $nt->getNamespace();
00149                         if ( $ns == NS_USER || $ns == NS_USER_TALK )
00150                                 return;
00151                 }
00152 
00153                 $oldlink = $link;
00154                 parent::findVariantLink( $link, $nt, $ignoreOtherCond );
00155                 if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
00156                         $link = $oldlink;
00157         }
00158 
00168         function markNoConversion( $text, $noParse = false ) {
00169                 if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
00170                     return parent::markNoConversion( $text );
00171                 return $text;
00172         }
00173 
00183         function autoConvert( $text, $toVariant = false ) {
00184                 global $wgTitle;
00185                 if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
00186                         $imagename = $wgTitle->getNsText();
00187                         if ( preg_match( "/^$imagename:/", $text ) ) return $text;
00188                 }
00189                 return parent::autoConvert( $text, $toVariant );
00190         }
00191 
00201         function translate( $text, $toVariant ) {
00202                 /* From Kazakh interface, maybe we need it later
00203                 $breaks = '[^\w\x80-\xff]';
00204                 // regexp for roman numbers
00205                 $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
00206                 $roman = '';
00207 
00208                 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
00209 
00210                 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
00211 
00212                 $m = array_shift($matches);
00213                 if( !isset( $this->mTables[$toVariant] ) ) {
00214                         throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
00215                 }
00216                 $ret = $this->mTables[$toVariant]->replace( $m[0] );
00217                 $mstart = $m[1]+strlen($m[0]);
00218                 foreach($matches as $m) {
00219                         $ret .= substr($text, $mstart, $m[1]-$mstart);
00220                         $ret .= parent::translate($m[0], $toVariant);
00221                         $mstart = $m[1] + strlen($m[0]);
00222                 }
00223 
00224                 return $ret;
00225                 */
00226 
00227                 if ( !isset( $this->mTables[$toVariant] ) ) {
00228                         throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
00229                 }
00230 
00231                 return parent::translate( $text, $toVariant );
00232         }
00233 }
00234 
00240 class LanguageKu extends LanguageKu_ku {
00241 
00242         function __construct() {
00243                 global $wgHooks;
00244                 parent::__construct();
00245 
00246                 $variants = array( 'ku', 'ku-arab', 'ku-latn' );
00247                 $variantfallbacks = array(
00248                         'ku'      => 'ku-latn',
00249                         'ku-arab' => 'ku-latn',
00250                         'ku-latn' => 'ku-arab',
00251                 );
00252 
00253                 $this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
00254                 $wgHooks['ArticleSaveComplete'][] = $this->mConverter;
00255         }
00256 }