[JSTesting] fix case typo in file path
[lhc/web/wiklou.git] / languages / classes / LanguageKu.php
1 <?php
2 require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
3 require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
4
5 /**
6 * Kurdish converter routines
7 *
8 * @ingroup Language
9 */
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',
16
17 // ک و => ku -- ist richtig
18 // و ك=> ku -- ist auch richtig
19
20 /* Doppel- und Halbvokale */
21 'ڵ' => 'll', # ll
22 'ڕ' => 'rr', # rr
23 'ا' => 'a',
24 # 'ئێ' => 'ê', # initial e
25 'ە' => 'e',
26 'ه‌' => 'e', # with one non-joiner
27 'ه‌‌' => 'e', # with two non-joiner
28 'ة' => 'e',
29 'ێ' => 'ê',
30 'ي' => 'î',
31 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
32 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
33 'ۆ' => 'o',
34 'و' => 'w',
35 'ئ' => '', # initial hemze should not be shown
36 '،' => ',',
37 'ع' => '\'', # ayn
38 '؟' => '?',
39
40 # digits
41 '٠' => '0', # &#x0660;
42 '١' => '1', # &#x0661;
43 '٢' => '2', # &#x0662;
44 '٣' => '3', # &#x0663;
45 '٤' => '4', # &#x0664;
46 '٥' => '5', # &#x0665;
47 '٦' => '6', # &#x0666;
48 '٧' => '7', # &#x0667;
49 '٨' => '8', # &#x0668;
50 '٩' => '9', # &#x0669;
51 );
52
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' => 'ز',
59
60
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' => 'ز',
66
67 /* Doppelkonsonanten */
68 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
69 # 'rr' => 'ڕ', # selbiges für doppel-r
70
71 /* Einzelne Großbuchstaben */
72 // ' C' => 'ج',
73
74 /* Vowels */
75 'a' => 'ا',
76 'e' => 'ە',
77 'ê' => 'ێ',
78 'i' => '',
79 'î' => 'ی',
80 'o' => 'ۆ',
81 'u' => 'و',
82 'û' => 'وو',
83 'w' => 'و',
84 ',' => '،',
85 '?' => '؟',
86
87 # Try to replace the leading vowel
88 ' a' => 'ئا ',
89 ' e' => 'ئە ',
90 ' ê' => 'ئێ ',
91 ' î' => 'ئی ',
92 ' o' => 'ئۆ ',
93 ' u' => 'ئو ',
94 ' û' => 'ئوو ',
95 'A' => 'ئا',
96 'E' => 'ئە',
97 'Ê' => 'ئێ',
98 'Î' => 'ئی',
99 'O' => 'ئۆ',
100 'U' => 'ئو',
101 'Û' => 'ئوو',
102 ' A' => 'ئا ',
103 ' E' => 'ئە ',
104 ' Ê' => 'ئێ ',
105 ' Î' => 'ئی ',
106 ' O' => 'ئۆ ',
107 ' U' => 'ئو ',
108 ' Û' => 'ئوو ',
109 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
110 # '\'' => 'ع',
111
112 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
113 # digits
114 '0' => '٠', # &#x0660;
115 '1' => '١', # &#x0661;
116 '2' => '٢', # &#x0662;
117 '3' => '٣', # &#x0663;
118 '4' => '٤', # &#x0664;
119 '5' => '٥', # &#x0665;
120 '6' => '٦', # &#x0666;
121 '7' => '٧', # &#x0667;
122 '8' => '٨', # &#x0668;
123 '9' => '٩', # &#x0669;
124 */
125 );
126
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()
132 );
133 }
134
135 /**
136 * A function wrapper:
137 * - if there is no selected variant, leave the link
138 * names as they were
139 * - do not try to find variants for usernames
140 *
141 * @param $link string
142 * @param $nt Title
143 * @param $ignoreOtherCond bool
144 */
145 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
146 // check for user namespace
147 if ( is_object( $nt ) ) {
148 $ns = $nt->getNamespace();
149 if ( $ns == NS_USER || $ns == NS_USER_TALK )
150 return;
151 }
152
153 $oldlink = $link;
154 parent::findVariantLink( $link, $nt, $ignoreOtherCond );
155 if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
156 $link = $oldlink;
157 }
158
159 /**
160 * We want our external link captions to be converted in variants,
161 * so we return the original text instead -{$text}-, except for URLs
162 *
163 * @param $text string
164 * @param $noParse bool
165 *
166 * @return string
167 */
168 function markNoConversion( $text, $noParse = false ) {
169 if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
170 return parent::markNoConversion( $text );
171 return $text;
172 }
173
174 /**
175 * An ugly function wrapper for parsing Image titles
176 * (to prevent image name conversion)
177 *
178 * @param $text string
179 * @param $toVariant bool
180 *
181 * @return string
182 */
183 function autoConvert( $text, $toVariant = false ) {
184 global $wgTitle;
185 if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
186 $imagename = $wgTitle->getNsText();
187 if ( preg_match( "/^$imagename:/", $text ) ) return $text;
188 }
189 return parent::autoConvert( $text, $toVariant );
190 }
191
192 /**
193 * It translates text into variant, specials:
194 * - ommiting roman numbers
195 *
196 * @param $text string
197 * @param $toVariant bool
198 *
199 * @return string
200 */
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})';
206 $roman = '';
207
208 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
209
210 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
211
212 $m = array_shift($matches);
213 if( !isset( $this->mTables[$toVariant] ) ) {
214 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
215 }
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]);
222 }
223
224 return $ret;
225 */
226
227 if ( !isset( $this->mTables[$toVariant] ) ) {
228 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
229 }
230
231 return parent::translate( $text, $toVariant );
232 }
233 }
234
235 /**
236 * Kurdish (Kurdî / كوردی)
237 *
238 * @ingroup Language
239 */
240 class LanguageKu extends LanguageKu_ku {
241
242 function __construct() {
243 global $wgHooks;
244 parent::__construct();
245
246 $variants = array( 'ku', 'ku-arab', 'ku-latn' );
247 $variantfallbacks = array(
248 'ku' => 'ku-latn',
249 'ku-arab' => 'ku-latn',
250 'ku-latn' => 'ku-arab',
251 );
252
253 $this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
254 $wgHooks['ArticleSaveComplete'][] = $this->mConverter;
255 }
256 }