2 require_once( dirname( __FILE__
) . '/../LanguageConverter.php' );
3 require_once( dirname( __FILE__
) . '/LanguageKu_ku.php' );
6 * Kurdish converter routines
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' => 'ز',
60 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
61 'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
62 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
63 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
64 'Y' => 'ی', 'Z' => 'ز',
66 /* Doppelkonsonanten */
67 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
68 # 'rr' => 'ڕ', # selbiges für doppel-r
70 /* Einzelne Großbuchstaben */
86 # Try to replace the leading vowel
108 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
111 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
113 '0' => '٠', # ٠
114 '1' => '١', # ١
115 '2' => '٢', # ٢
116 '3' => '٣', # ٣
117 '4' => '٤', # ٤
118 '5' => '٥', # ٥
119 '6' => '٦', # ٦
120 '7' => '٧', # ٧
121 '8' => '٨', # ٨
122 '9' => '٩', # ٩
126 function loadDefaultTables() {
127 $this->mTables
= array(
128 'ku-latn' => new ReplacementArray( $this->mArabicToLatin
),
129 'ku-arab' => new ReplacementArray( $this->mLatinToArabic
),
130 'ku' => new ReplacementArray()
135 * A function wrapper:
136 * - if there is no selected variant, leave the link
138 * - do not try to find variants for usernames
140 * @param $link string
142 * @param $ignoreOtherCond bool
144 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
145 // check for user namespace
146 if ( is_object( $nt ) ) {
147 $ns = $nt->getNamespace();
148 if ( $ns == NS_USER ||
$ns == NS_USER_TALK
)
153 parent
::findVariantLink( $link, $nt, $ignoreOtherCond );
154 if ( $this->getPreferredVariant() == $this->mMainLanguageCode
)
159 * We want our external link captions to be converted in variants,
160 * so we return the original text instead -{$text}-, except for URLs
162 * @param $text string
163 * @param $noParse bool
167 function markNoConversion( $text, $noParse = false ) {
168 if ( $noParse ||
preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
169 return parent
::markNoConversion( $text );
174 * An ugly function wrapper for parsing Image titles
175 * (to prevent image name conversion)
177 * @param $text string
178 * @param $toVariant bool
182 function autoConvert( $text, $toVariant = false ) {
184 if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE
) {
185 $imagename = $wgTitle->getNsText();
186 if ( preg_match( "/^$imagename:/", $text ) ) return $text;
188 return parent
::autoConvert( $text, $toVariant );
192 * It translates text into variant, specials:
193 * - ommiting roman numbers
195 * @param $text string
196 * @param $toVariant bool
198 * @throws MWException
201 function translate( $text, $toVariant ) {
202 /* From Kazakh interface, maybe we need it later
203 $breaks = '[^\w\x80-\xff]';
204 // regexp for roman numbers
205 $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
208 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
210 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
212 $m = array_shift($matches);
213 if( !isset( $this->mTables[$toVariant] ) ) {
214 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
216 $ret = $this->mTables[$toVariant]->replace( $m[0] );
217 $mstart = $m[1]+strlen($m[0]);
218 foreach($matches as $m) {
219 $ret .= substr($text, $mstart, $m[1]-$mstart);
220 $ret .= parent::translate($m[0], $toVariant);
221 $mstart = $m[1] + strlen($m[0]);
227 if ( !isset( $this->mTables
[$toVariant] ) ) {
228 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables
) ) );
231 return parent
::translate( $text, $toVariant );
236 * Kurdish (Kurdî / كوردی)
240 class LanguageKu
extends LanguageKu_ku
{
242 function __construct() {
244 parent
::__construct();
246 $variants = array( 'ku', 'ku-arab', 'ku-latn' );
247 $variantfallbacks = array(
249 'ku-arab' => 'ku-latn',
250 'ku-latn' => 'ku-arab',
253 $this->mConverter
= new KuConverter( $this, 'ku', $variants, $variantfallbacks );
254 $wgHooks['ArticleSaveComplete'][] = $this->mConverter
;