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