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