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