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