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