Revert commenting out in r72239 (leaving whitespace changes
[lhc/web/wiklou.git] / languages / classes / LanguageKk_cyrl.php
1 <?php
2 /** Kazakh (Қазақша)
3 *
4 * @ingroup Language
5 */
6
7 class LanguageKk_cyrl extends Language {
8
9 # Convert from the nominative form of a noun to some other case
10 # Invoked with {{GRAMMAR:case|word}}
11 /**
12 * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
13 */
14
15 function convertGrammarKk_cyrl( $word, $case ) {
16 global $wgGrammarForms;
17 if ( isset( $wgGrammarForms['kk-kz'][$case][$word] ) ) {
18 return $wgGrammarForms['kk-kz'][$case][$word];
19 }
20 if ( isset( $wgGrammarForms['kk-cyrl'][$case][$word] ) ) {
21 return $wgGrammarForms['kk-cyrl'][$case][$word];
22 }
23 // Set up some constants...
24 // Vowels in last syllable
25 $frontVowels = array( "е", "ө", "ү", "і", "ә", "э", "я", "ё", "и" );
26 $backVowels = array( "а", "о", "ұ", "ы" );
27 $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" );
28 // Preceding letters
29 $Nasals = array( "м", "н", "ң" );
30 $Sonants = array( "и", "й", "л", "р", "у", "ю" );
31 $Consonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
32 $Sibilants = array( "ж", "з" );
33 $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" );
34
35 // Possessives
36 $firstPerson = array( "м", "ң" ); // 1st singular, 2nd unformal
37 $secondPerson = array( "з" ); // 1st plural, 2nd formal
38 $thirdPerson = array( "ы", "і" ); // 3rd
39
40 $lastLetter = $this->lastLetter( $word, $allVowels );
41 $wordEnding =& $lastLetter[0];
42 $wordLastVowel =& $lastLetter[1];
43
44 // Now convert the word
45 switch ( $case ) {
46 case "dc1":
47 case "genitive": # ilik
48 if ( in_array( $wordEnding, $Consonants ) ) {
49 if ( in_array( $wordLastVowel, $frontVowels ) ) {
50 $word = $word . "тің";
51 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
52 $word = $word . "тың";
53 }
54 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
55 if ( in_array( $wordLastVowel, $frontVowels ) ) {
56 $word = $word . "нің";
57 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
58 $word = $word . "ның";
59 }
60 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
61 if ( in_array( $wordLastVowel, $frontVowels ) ) {
62 $word = $word . "дің";
63 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
64 $word = $word . "дың";
65 }
66 }
67 break;
68 case "dc2":
69 case "dative": # barıs
70 if ( in_array( $wordEnding, $Consonants ) ) {
71 if ( in_array( $wordLastVowel, $frontVowels ) ) {
72 $word = $word . "ке";
73 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
74 $word = $word . "қа";
75 }
76 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
77 if ( in_array( $wordLastVowel, $frontVowels ) ) {
78 $word = $word . "ге";
79 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
80 $word = $word . "ға";
81 }
82 }
83 break;
84 case "dc21":
85 case "possessive dative": # täweldık + barıs
86 if ( in_array( $wordEnding, $firstPerson ) ) {
87 if ( in_array( $wordLastVowel, $frontVowels ) ) {
88 $word = $word . "е";
89 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
90 $word = $word . "а";
91 }
92 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
93 if ( in_array( $wordLastVowel, $frontVowels ) ) {
94 $word = $word . "ге";
95 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
96 $word = $word . "ға";
97 }
98 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
99 if ( in_array( $wordLastVowel, $frontVowels ) ) {
100 $word = $word . "не";
101 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
102 $word = $word . "на";
103 }
104 }
105 break;
106 case "dc3":
107 case "accusative": # tabıs
108 if ( in_array( $wordEnding, $Consonants ) ) {
109 if ( in_array( $wordLastVowel, $frontVowels ) ) {
110 $word = $word . "ті";
111 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
112 $word = $word . "ты";
113 }
114 } elseif ( in_array( $wordEnding, $allVowels ) ) {
115 if ( in_array( $wordLastVowel, $frontVowels ) ) {
116 $word = $word . "ні";
117 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
118 $word = $word . "ны";
119 }
120 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
121 if ( in_array( $wordLastVowel, $frontVowels ) ) {
122 $word = $word . "ді";
123 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
124 $word = $word . "ды";
125 }
126 }
127 break;
128 case "dc31":
129 case "possessive accusative": # täweldık + tabıs
130 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
131 if ( in_array( $wordLastVowel, $frontVowels ) ) {
132 $word = $word . "ді";
133 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
134 $word = $word . "ды";
135 }
136 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
137 $word = $word . "н";
138 }
139 break;
140 case "dc4":
141 case "locative": # jatıs
142 if ( in_array( $wordEnding, $Consonants ) ) {
143 if ( in_array( $wordLastVowel, $frontVowels ) ) {
144 $word = $word . "те";
145 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
146 $word = $word . "та";
147 }
148 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
149 if ( in_array( $wordLastVowel, $frontVowels ) ) {
150 $word = $word . "де";
151 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
152 $word = $word . "да";
153 }
154 }
155 break;
156 case "dc41":
157 case "possessive locative": # täweldık + jatıs
158 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
159 if ( in_array( $wordLastVowel, $frontVowels ) ) {
160 $word = $word . "де";
161 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
162 $word = $word . "да";
163 }
164 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
165 if ( in_array( $wordLastVowel, $frontVowels ) ) {
166 $word = $word . "нде";
167 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
168 $word = $word . "нда";
169 }
170 }
171 break;
172 case "dc5":
173 case "ablative": # şığıs
174 if ( in_array( $wordEnding, $Consonants ) ) {
175 if ( in_array( $wordLastVowel, $frontVowels ) ) {
176 $word = $word . "тен";
177 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
178 $word = $word . "тан";
179 }
180 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
181 if ( in_array( $wordLastVowel, $frontVowels ) ) {
182 $word = $word . "ден";
183 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
184 $word = $word . "дан";
185 }
186 } elseif ( in_array( $wordEnding, $Nasals ) ) {
187 if ( in_array( $wordLastVowel, $frontVowels ) ) {
188 $word = $word . "нен";
189 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
190 $word = $word . "нан";
191 }
192 }
193 break;
194 case "dc51":
195 case "possessive ablative": # täweldık + şığıs
196 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
197 if ( in_array( $wordLastVowel, $frontVowels ) ) {
198 $word = $word . "нен";
199 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
200 $word = $word . "нан";
201 }
202 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
203 if ( in_array( $wordLastVowel, $frontVowels ) ) {
204 $word = $word . "ден";
205 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
206 $word = $word . "дан";
207 }
208 }
209 break;
210 case "dc6":
211 case "comitative": # kömektes
212 if ( in_array( $wordEnding, $Consonants ) ) {
213 $word = $word . "пен";
214 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
215 $word = $word . "мен";
216 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
217 $word = $word . "бен";
218 }
219 break;
220 case "dc61":
221 case "possessive comitative": # täweldık + kömektes
222 if ( in_array( $wordEnding, $Consonants ) ) {
223 $word = $word . "пенен";
224 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
225 $word = $word . "менен";
226 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
227 $word = $word . "бенен";
228 }
229 break;
230 default: # dc0 #nominative #ataw
231 }
232 return $word;
233 }
234
235 function convertGrammarKk_latn( $word, $case ) {
236 global $wgGrammarForms;
237 if ( isset( $wgGrammarForms['kk-tr'][$case][$word] ) ) {
238 return $wgGrammarForms['kk-tr'][$case][$word];
239 }
240 if ( isset( $wgGrammarForms['kk-latn'][$case][$word] ) ) {
241 return $wgGrammarForms['kk-latn'][$case][$word];
242 }
243 // Set up some constants...
244 // Vowels in last syllable
245 $frontVowels = array( "e", "ö", "ü", "i", "ä", "é" );
246 $backVowels = array( "a", "o", "u", "ı" );
247 $allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" );
248 // Preceding letters
249 $Nasals = array( "m", "n", "ñ" );
250 $Sonants = array( "ï", "y", "ý", "l", "r", "w" );
251 $Consonants = array( "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç", "b", "v", "g", "d" );
252 $Sibilants = array( "j", "z" );
253 $Sonorants = array( "ï", "y", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z" );
254
255 // Possessives
256 $firstPerson = array( "m", "ñ" ); // 1st singular, 2nd unformal
257 $secondPerson = array( "z" ); // 1st plural, 2nd formal
258 $thirdPerson = array( "ı", "i" ); // 3rd
259
260 $lastLetter = $this->lastLetter( $word, $allVowels );
261 $wordEnding =& $lastLetter[0];
262 $wordLastVowel =& $lastLetter[1];
263
264 // Now convert the word
265 switch ( $case ) {
266 case "dc1":
267 case "genitive": # ilik
268 if ( in_array( $wordEnding, $Consonants ) ) {
269 if ( in_array( $wordLastVowel, $frontVowels ) ) {
270 $word = $word . "tiñ";
271 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
272 $word = $word . "tıñ";
273 }
274 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
275 if ( in_array( $wordLastVowel, $frontVowels ) ) {
276 $word = $word . "niñ";
277 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
278 $word = $word . "nıñ";
279 }
280 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
281 if ( in_array( $wordLastVowel, $frontVowels ) ) {
282 $word = $word . "diñ";
283 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
284 $word = $word . "dıñ";
285 }
286 }
287 break;
288 case "dc2":
289 case "dative": # barıs
290 if ( in_array( $wordEnding, $Consonants ) ) {
291 if ( in_array( $wordLastVowel, $frontVowels ) ) {
292 $word = $word . "ke";
293 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
294 $word = $word . "qa";
295 }
296 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
297 if ( in_array( $wordLastVowel, $frontVowels ) ) {
298 $word = $word . "ge";
299 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
300 $word = $word . "ğa";
301 }
302 }
303 break;
304 case "dc21":
305 case "possessive dative": # täweldık + barıs
306 if ( in_array( $wordEnding, $firstPerson ) ) {
307 if ( in_array( $wordLastVowel, $frontVowels ) ) {
308 $word = $word . "e";
309 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
310 $word = $word . "a";
311 }
312 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
313 if ( in_array( $wordLastVowel, $frontVowels ) ) {
314 $word = $word . "ge";
315 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
316 $word = $word . "ğa";
317 }
318 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
319 if ( in_array( $wordLastVowel, $frontVowels ) ) {
320 $word = $word . "ne";
321 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
322 $word = $word . "na";
323 }
324 }
325 break;
326 case "dc3":
327 case "accusative": # tabıs
328 if ( in_array( $wordEnding, $Consonants ) ) {
329 if ( in_array( $wordLastVowel, $frontVowels ) ) {
330 $word = $word . "ti";
331 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
332 $word = $word . "tı";
333 }
334 } elseif ( in_array( $wordEnding, $allVowels ) ) {
335 if ( in_array( $wordLastVowel, $frontVowels ) ) {
336 $word = $word . "ni";
337 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
338 $word = $word . "nı";
339 }
340 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
341 if ( in_array( $wordLastVowel, $frontVowels ) ) {
342 $word = $word . "di";
343 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
344 $word = $word . "dı";
345 }
346 }
347 break;
348 case "dc31":
349 case "possessive accusative": # täweldık + tabıs
350 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
351 if ( in_array( $wordLastVowel, $frontVowels ) ) {
352 $word = $word . "di";
353 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
354 $word = $word . "dı";
355 }
356 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
357 $word = $word . "n";
358 }
359 break;
360 case "dc4":
361 case "locative": # jatıs
362 if ( in_array( $wordEnding, $Consonants ) ) {
363 if ( in_array( $wordLastVowel, $frontVowels ) ) {
364 $word = $word . "te";
365 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
366 $word = $word . "ta";
367 }
368 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
369 if ( in_array( $wordLastVowel, $frontVowels ) ) {
370 $word = $word . "de";
371 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
372 $word = $word . "da";
373 }
374 }
375 break;
376 case "dc41":
377 case "possessive locative": # täweldık + jatıs
378 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
379 if ( in_array( $wordLastVowel, $frontVowels ) ) {
380 $word = $word . "de";
381 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
382 $word = $word . "da";
383 }
384 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
385 if ( in_array( $wordLastVowel, $frontVowels ) ) {
386 $word = $word . "nde";
387 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
388 $word = $word . "nda";
389 }
390 }
391 break;
392 case "dc5":
393 case "ablative": # şığıs
394 if ( in_array( $wordEnding, $Consonants ) ) {
395 if ( in_array( $wordLastVowel, $frontVowels ) ) {
396 $word = $word . "ten";
397 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
398 $word = $word . "tan";
399 }
400 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
401 if ( in_array( $wordLastVowel, $frontVowels ) ) {
402 $word = $word . "den";
403 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
404 $word = $word . "dan";
405 }
406 } elseif ( in_array( $wordEnding, $Nasals ) ) {
407 if ( in_array( $wordLastVowel, $frontVowels ) ) {
408 $word = $word . "nen";
409 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
410 $word = $word . "nan";
411 }
412 }
413 break;
414 case "dc51":
415 case "possessive ablative": # täweldık + şığıs
416 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
417 if ( in_array( $wordLastVowel, $frontVowels ) ) {
418 $word = $word . "nen";
419 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
420 $word = $word . "nan";
421 }
422 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
423 if ( in_array( $wordLastVowel, $frontVowels ) ) {
424 $word = $word . "den";
425 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
426 $word = $word . "dan";
427 }
428 }
429 break;
430 case "dc6":
431 case "comitative": # kömektes
432 if ( in_array( $wordEnding, $Consonants ) ) {
433 $word = $word . "pen";
434 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
435 $word = $word . "men";
436 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
437 $word = $word . "ben";
438 }
439 break;
440 case "dc61":
441 case "possessive comitative": # täweldık + kömektes
442 if ( in_array( $wordEnding, $Consonants ) ) {
443 $word = $word . "penen";
444 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
445 $word = $word . "menen";
446 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
447 $word = $word . "benen";
448 }
449 break;
450 default: # dc0 #nominative #ataw
451 }
452 return $word;
453 }
454
455 function convertGrammarKk_arab( $word, $case ) {
456 global $wgGrammarForms;
457 if ( isset( $wgGrammarForms['kk-cn'][$case][$word] ) ) {
458 return $wgGrammarForms['kk-cn'][$case][$word];
459 }
460 if ( isset( $wgGrammarForms['kk-arab'][$case][$word] ) ) {
461 return $wgGrammarForms['kk-arab'][$case][$word];
462 }
463 // Set up some constants...
464 // Vowels in last syllable
465 $frontVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە" );
466 $backVowels = array( "ا", "و", "ۇ", "ى" );
467 $allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" );
468 // Preceding letters
469 $Nasals = array( "م", "ن", "ڭ" );
470 $Sonants = array( "ي", "ي", "ل", "ر", "ۋ" );
471 $Consonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" );
472 $Sibilants = array( "ج", "ز" );
473 $Sonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز" );
474
475 // Possessives
476 $firstPerson = array( "م", "ڭ" ); // 1st singular, 2nd unformal
477 $secondPerson = array( "ز" ); // 1st plural, 2nd formal
478 $thirdPerson = array( "ى", "ٸ" ); // 3rd
479
480 $lastLetter = $this->lastLetter( $word, $allVowels );
481 $wordEnding = $lastLetter[0];
482 $wordLastVowel = $lastLetter[1];
483
484 // Now convert the word
485 switch ( $case ) {
486 case "dc1":
487 case "genitive": # ilik
488 if ( in_array( $wordEnding, $Consonants ) ) {
489 if ( in_array( $wordLastVowel, $frontVowels ) ) {
490 $word = $word . "تٸڭ";
491 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
492 $word = $word . "تىڭ";
493 }
494 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
495 if ( in_array( $wordLastVowel, $frontVowels ) ) {
496 $word = $word . "نٸڭ";
497 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
498 $word = $word . "نىڭ";
499 }
500 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
501 if ( in_array( $wordLastVowel, $frontVowels ) ) {
502 $word = $word . "دٸڭ";
503 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
504 $word = $word . "دىڭ";
505 }
506 }
507 break;
508 case "dc2":
509 case "dative": # barıs
510 if ( in_array( $wordEnding, $Consonants ) ) {
511 if ( in_array( $wordLastVowel, $frontVowels ) ) {
512 $word = $word . "كە";
513 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
514 $word = $word . "قا";
515 }
516 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
517 if ( in_array( $wordLastVowel, $frontVowels ) ) {
518 $word = $word . "گە";
519 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
520 $word = $word . "عا";
521 }
522 }
523 break;
524 case "dc21":
525 case "possessive dative": # täweldık + barıs
526 if ( in_array( $wordEnding, $firstPerson ) ) {
527 if ( in_array( $wordLastVowel, $frontVowels ) ) {
528 $word = $word . "ە";
529 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
530 $word = $word . "ا";
531 }
532 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
533 if ( in_array( $wordLastVowel, $frontVowels ) ) {
534 $word = $word . "گە";
535 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
536 $word = $word . "عا";
537 }
538 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
539 if ( in_array( $wordLastVowel, $frontVowels ) ) {
540 $word = $word . "نە";
541 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
542 $word = $word . "نا";
543 }
544 }
545 break;
546 case "dc3":
547 case "accusative": # tabıs
548 if ( in_array( $wordEnding, $Consonants ) ) {
549 if ( in_array( $wordLastVowel, $frontVowels ) ) {
550 $word = $word . "تٸ";
551 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
552 $word = $word . "تى";
553 }
554 } elseif ( in_array( $wordEnding, $allVowels ) ) {
555 if ( in_array( $wordLastVowel, $frontVowels ) ) {
556 $word = $word . "نٸ";
557 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
558 $word = $word . "نى";
559 }
560 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
561 if ( in_array( $wordLastVowel, $frontVowels ) ) {
562 $word = $word . "دٸ";
563 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
564 $word = $word . "دى";
565 }
566 }
567 break;
568 case "dc31":
569 case "possessive accusative": # täweldık + tabıs
570 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
571 if ( in_array( $wordLastVowel, $frontVowels ) ) {
572 $word = $word . "دٸ";
573 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
574 $word = $word . "دى";
575 }
576 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
577 $word = $word . "ن";
578 }
579 break;
580 case "dc4":
581 case "locative": # jatıs
582 if ( in_array( $wordEnding, $Consonants ) ) {
583 if ( in_array( $wordLastVowel, $frontVowels ) ) {
584 $word = $word . "تە";
585 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
586 $word = $word . "تا";
587 }
588 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
589 if ( in_array( $wordLastVowel, $frontVowels ) ) {
590 $word = $word . "دە";
591 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
592 $word = $word . "دا";
593 }
594 }
595 break;
596 case "dc41":
597 case "possessive locative": # täweldık + jatıs
598 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
599 if ( in_array( $wordLastVowel, $frontVowels ) ) {
600 $word = $word . "دە";
601 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
602 $word = $word . "دا";
603 }
604 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
605 if ( in_array( $wordLastVowel, $frontVowels ) ) {
606 $word = $word . "ندە";
607 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
608 $word = $word . "ندا";
609 }
610 }
611 break;
612 case "dc5":
613 case "ablative": # şığıs
614 if ( in_array( $wordEnding, $Consonants ) ) {
615 if ( in_array( $wordLastVowel, $frontVowels ) ) {
616 $word = $word . "تەن";
617 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
618 $word = $word . "تان";
619 }
620 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
621 if ( in_array( $wordLastVowel, $frontVowels ) ) {
622 $word = $word . "دەن";
623 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
624 $word = $word . "دان";
625 }
626 } elseif ( in_array( $wordEnding, $Nasals ) ) {
627 if ( in_array( $wordLastVowel, $frontVowels ) ) {
628 $word = $word . "نەن";
629 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
630 $word = $word . "نان";
631 }
632 }
633 break;
634 case "dc51":
635 case "possessive ablative": # täweldık + şığıs
636 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
637 if ( in_array( $wordLastVowel, $frontVowels ) ) {
638 $word = $word . "نەن";
639 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
640 $word = $word . "نان";
641 }
642 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
643 if ( in_array( $wordLastVowel, $frontVowels ) ) {
644 $word = $word . "دەن";
645 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
646 $word = $word . "دان";
647 }
648 }
649 break;
650 case "dc6":
651 case "comitative": # kömektes
652 if ( in_array( $wordEnding, $Consonants ) ) {
653 $word = $word . "پەن";
654 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
655 $word = $word . "مەن";
656 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
657 $word = $word . "بەن";
658 }
659 break;
660 case "dc61":
661 case "possessive comitative": # täweldık + kömektes
662 if ( in_array( $wordEnding, $Consonants ) ) {
663 $word = $word . "پەنەن";
664 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
665 $word = $word . "مەنەن";
666 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
667 $word = $word . "بەنەن";
668 }
669 break;
670 default: # dc0 #nominative #ataw
671 }
672 return $word;
673 }
674
675 function lastLetter( $word, $allVowels ) {
676 $lastLetter = array();
677 $ar = array();
678
679 // Put the word in a form we can play with since we're using UTF-8
680 $ar = preg_split( '//u', parent::lc( $word ), -1, PREG_SPLIT_NO_EMPTY );
681
682 // Here's an array with the order of the letters in the word reversed
683 // so we can find a match quicker *shrug*
684 $wordReversed = array_reverse( $ar );
685
686 // Here's the last letter in the word
687 $lastLetter[0] = $ar[count( $ar ) - 1];
688
689 // Find the last vowel in the word
690 $lastLetter[1] = NULL;
691 foreach ( $wordReversed as $xvalue ) {
692 foreach ( $allVowels as $yvalue ) {
693 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
694 $lastLetter[1] = $xvalue;
695 break;
696 } else {
697 continue;
698 }
699 }
700 if ( $lastLetter[1] !== NULL ) {
701 break;
702 } else {
703 continue;
704 }
705 }
706
707 return $lastLetter;
708 }
709
710 /**
711 * Avoid grouping whole numbers between 0 to 9999
712 */
713 function commafy( $_ ) {
714 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
715 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
716 } else {
717 return $_;
718 }
719 }
720 }