2 require_once( dirname(__FILE__
).'/../LanguageConverter.php' );
3 require_once( dirname(__FILE__
).'/LanguageKu_ku.php' );
10 class KuConverter
extends LanguageConverter
{
11 var $mArabicToLatin = array(
12 'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
13 'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
14 'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
15 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
17 // ک و => ku -- ist richtig
18 // و ك=> ku -- ist auch richtig
20 /* Doppel- und Halbvokale */
24 # 'ئێ' => 'ê', # initial e
26 'ه' => 'e', # with one non-joiner
27 'ه' => 'e', # with two non-joiner
31 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
32 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
35 'ئ' => '', # initial hemze should not be shown
41 '٠' => '0', # ٠
42 '١' => '1', # ١
43 '٢' => '2', # ٢
44 '٣' => '3', # ٣
45 '٤' => '4', # ٤
46 '٥' => '5', # ٥
47 '٦' => '6', # ٦
48 '٧' => '7', # ٧
49 '٨' => '8', # ٨
50 '٩' => '9', # ٩
53 var $mLatinToArabic = array(
54 'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
55 'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
56 'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
57 't' => 'ت', 'v' => 'ڤ',
58 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
61 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
62 'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
63 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
64 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
65 'Y' => 'ی', 'Z' => 'ز',
67 /* Doppelkonsonanten */
68 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
69 # 'rr' => 'ڕ', # selbiges für doppel-r
71 /* Einzelne Großbuchstaben */
87 # Try to replace the leading vowel
109 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
112 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
114 '0' => '٠', # ٠
115 '1' => '١', # ١
116 '2' => '٢', # ٢
117 '3' => '٣', # ٣
118 '4' => '٤', # ٤
119 '5' => '٥', # ٥
120 '6' => '٦', # ٦
121 '7' => '٧', # ٧
122 '8' => '٨', # ٨
123 '9' => '٩', # ٩
127 function loadDefaultTables() {
128 $this->mTables
= array(
129 'ku-latn' => new ReplacementArray( $this->mArabicToLatin
),
130 'ku-arab' => new ReplacementArray( $this->mLatinToArabic
),
131 'ku' => new ReplacementArray()
136 * A function wrapper:
137 * - if there is no selected variant, leave the link
139 * - do not try to find variants for usernames
141 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
142 // check for user namespace
144 $ns = $nt->getNamespace();
145 if($ns==NS_USER ||
$ns==NS_USER_TALK
)
150 parent
::findVariantLink( $link, $nt, $ignoreOtherCond );
151 if( $this->getPreferredVariant() == $this->mMainLanguageCode
)
156 * We want our external link captions to be converted in variants,
157 * so we return the original text instead -{$text}-, except for URLs
159 function markNoConversion($text, $noParse=false) {
160 if($noParse ||
preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text))
161 return parent
::markNoConversion($text);
166 * An ugly function wrapper for parsing Image titles
167 * (to prevent image name conversion)
169 function autoConvert($text, $toVariant=false) {
171 if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE
){
172 $imagename = $wgTitle->getNsText();
173 if(preg_match("/^$imagename:/",$text)) return $text;
175 return parent
::autoConvert($text,$toVariant);
179 * It translates text into variant, specials:
180 * - ommiting roman numbers
182 function translate($text, $toVariant){
183 $breaks = '[^\w\x80-\xff]';
185 /* From Kazakh interface, maybe we need it later
187 // regexp for roman numbers
188 $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
191 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
193 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
195 $m = array_shift($matches);
196 if( !isset( $this->mTables[$toVariant] ) ) {
197 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
199 $ret = $this->mTables[$toVariant]->replace( $m[0] );
200 $mstart = $m[1]+strlen($m[0]);
201 foreach($matches as $m) {
202 $ret .= substr($text, $mstart, $m[1]-$mstart);
203 $ret .= parent::translate($m[0], $toVariant);
204 $mstart = $m[1] + strlen($m[0]);
210 if( !isset( $this->mTables
[$toVariant] ) ) {
211 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables
) ) );
214 return parent
::translate( $text, $toVariant );
221 class LanguageKu
extends LanguageKu_ku
{
223 function __construct() {
225 parent
::__construct();
227 $variants = array( 'ku', 'ku-arab', 'ku-latn' );
228 $variantfallbacks = array(
230 'ku-arab' => 'ku-latn',
231 'ku-latn' => 'ku-arab',
234 $this->mConverter
= new KuConverter( $this, 'ku', $variants, $variantfallbacks );
235 $wgHooks['ArticleSaveComplete'][] = $this->mConverter
;