* (bug 12145) Update Kazakh translations, adding kk-variants
[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
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 <?php
735 /** Kazakh (Қазақша)
736 *
737 *
738 * @addtogroup Language
739 */
740
741
742 class LanguageKk_kz extends Language {
743
744 # Convert from the nominative form of a noun to some other case
745 # Invoked with {{GRAMMAR:case|word}}
746 /**
747 * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
748 */
749 function convertGrammar( $word, $case, $variant ) {
750 global $wgGrammarForms;
751
752 if ($variant='kk-kz') { $word = LanguageKk_kz::convertGrammarKk_kz( $word, $case ); }
753 if ($variant='kk-tr') { $word = LanguageKk_kz::convertGrammarKk_tr( $word, $case ); }
754 if ($variant='kk-cn') { $word = LanguageKk_kz::convertGrammarKk_cn( $word, $case ); }
755 return $word;
756 }
757
758 function convertGrammarKk_kz( $word, $case ) {
759
760 if ( isset( $wgGrammarForms['kk-kz'][$case][$word] ) ) {
761 return $wgGrammarForms['kk-kz'][$case][$word];
762 }
763 // Set up some constants...
764 // Vowels in last syllable
765 $frontVowels = array( "е", "ө", "ү", "і", "ә", "э" );
766 $backVowels = array( "а", "о", "ұ", "ы", "я", "ё" );
767 $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё" );
768 // Preceding letters
769 $preVowels = $allVowels;
770 $preNasals = array( "м", "н", "ң" );
771 $preSonants = array( "и", "й", "л", "р", "у", "ю");
772 # $preVoiceds = array( "б", "в", "г", "ғ", "д", "ж", "з", "һ" );
773 # $preVoicelesses = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ" );
774 $preConsonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
775 $preEzhZet = array( "ж", "з" );
776 $preSonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з");
777
778 // Possessives
779 $firsts = array( "м", "ң" ); // 1st singular, 2nd unformal
780 $seconds = array( "з" ); // 1st plural, 2nd formal
781 $thirds = array( "ы", "і" ); // 3rd
782 // Put the word in a form we can play with since we're using UTF-8
783 $ar = array();
784 $ar = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY);
785 $wordEnding = $ar[count( $ar ) - 1]; //Here's the last letter in the word
786 $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*
787
788 $wordLastVowel = LanguageKk_kz::lastVowel( $wordReversed, $allVowels );
789 // Now convert the word
790 switch ( $case ) {
791 case "dc1":
792 case "genitive": #ilik
793 if ( in_array( $wordEnding, $preConsonants ) ) {
794 if ( in_array( $wordLastVowel, $frontVowels ) ) {
795 $word = implode( "", $ar ) . "тің";
796 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
797 $word = implode( "", $ar ) . "тың";
798 }
799 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) ) {
800 if ( in_array( $wordLastVowel, $frontVowels ) ) {
801 $word = implode( "", $ar ) . "нің";
802 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
803 $word = implode( "", $ar ) . "ның";
804 }
805 } elseif ( in_array( $wordEnding, $preSonants ) || in_array( $wordEnding, $preEzhZet )) {
806 if ( in_array( $wordLastVowel, $frontVowels ) ) {
807 $word = implode( "", $ar ) . "дің";
808 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
809 $word = implode( "", $ar ) . "дың";
810 }
811 }
812 break;
813 case "dc2":
814 case "dative": #barıs
815 if ( in_array( $wordEnding, $preConsonants ) ) {
816 if ( in_array( $wordLastVowel, $frontVowels ) ) {
817 $word = implode( "", $ar ) . "ке";
818 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
819 $word = implode( "", $ar ) . "қа";
820 }
821 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
822 if ( in_array( $wordLastVowel, $frontVowels ) ) {
823 $word = implode( "", $ar ) . "ге";
824 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
825 $word = implode( "", $ar ) . "ға";
826 }
827 }
828 break;
829 case "dc21":
830 case "possessive dative": #täweldık + barıs
831 if ( in_array( $wordEnding, $firsts ) ) {
832 if ( in_array( $wordLastVowel, $frontVowels ) ) {
833 $word = implode( "", $ar ) . "е";
834 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
835 $word = implode( "", $ar ) . "а";
836 }
837 } elseif ( in_array( $wordEnding, $seconds ) ) {
838 if ( in_array( $wordLastVowel, $frontVowels ) ) {
839 $word = implode( "", $ar ) . "ге";
840 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
841 $word = implode( "", $ar ) . "ға";
842 }
843 } elseif ( in_array( $wordEnding, $thirds ) ) {
844 if ( in_array( $wordLastVowel, $frontVowels ) ) {
845 $word = implode( "", $ar ) . "не";
846 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
847 $word = implode( "", $ar ) . "на";
848 }
849 }
850 break;
851 case "dc3":
852 case "accusative": #tabıs
853 if ( in_array( $wordEnding, $preConsonants ) ) {
854 if ( in_array( $wordLastVowel, $frontVowels ) ) {
855 $word = implode( "", $ar ) . "ті";
856 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
857 $word = implode( "", $ar ) . "ты";
858 }
859 } elseif ( in_array( $wordEnding, $preVowels ) ) {
860 if ( in_array($wordLastVowel, $frontVowels ) ) {
861 $word = implode( "", $ar ) . "ні";
862 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
863 $word = implode( "", $ar ) . "ны";
864 }
865 } elseif ( in_array( $wordEnding, $preSonorants) ) {
866 if ( in_array( $wordLastVowel, $frontVowels) ) {
867 $word = implode( "", $ar ) . "ді";
868 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
869 $word = implode( "", $ar ) . "ды";
870 }
871 }
872 break;
873 case "dc31":
874 case "possessive accusative": #täweldık + tabıs
875 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
876 if ( in_array( $wordLastVowel, $frontVowels ) ) {
877 $word = implode( "", $ar ) . "ді";
878 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
879 $word = implode( "", $ar ) . "ды";
880 }
881 } elseif ( in_array( $wordEnding, $thirds ) ) {
882 $word = implode( "", $ar ) . "н";
883 }
884 break;
885 case "dc4":
886 case "locative": #jatıs
887 if ( in_array( $wordEnding, $preConsonants ) ) {
888 if ( in_array( $wordLastVowel, $frontVowels ) ) {
889 $word = implode( "", $ar ) . "те";
890 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
891 $word = implode( "", $ar ) . "та";
892 }
893 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
894 if ( in_array( $wordLastVowel, $frontVowels) ) {
895 $word = implode( "", $ar ) . "де";
896 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
897 $word = implode( "",$ar ) . "да";
898 }
899 }
900 break;
901 case "dc41":
902 case "possessive locative": #täweldık + jatıs
903 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
904 if ( in_array( $wordLastVowel, $frontVowels ) ) {
905 $word = implode( "", $ar ) . "де";
906 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
907 $word = implode( "", $ar ) . "да";
908 }
909 } elseif ( in_array( $wordEnding, $thirds ) ) {
910 if ( in_array( $wordLastVowel, $frontVowels) ) {
911 $word = implode( "", $ar ) . "нде";
912 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
913 $word = implode( "",$ar ) . "нда";
914 }
915 }
916 break;
917 case "dc5":
918 case "ablative": #şığıs
919 if ( in_array( $wordEnding, $preConsonants ) ) {
920 if ( in_array( $wordLastVowel, $frontVowels ) ) {
921 $word = implode( "", $ar ) . "тен";
922 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
923 $word = implode( "", $ar ) . "тан";
924 }
925 } elseif ( in_array($wordEnding, $preVowels ) || in_array($wordEnding, $preSonants ) || in_array($wordEnding, $preEzhZet ) ) {
926 if ( in_array( $wordLastVowel, $frontVowels ) ) {
927 $word = implode( "", $ar ) . "ден";
928 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
929 $word = implode( "", $ar ) . "дан";
930 }
931 } elseif ( in_array($wordEnding, $preNasals ) ) {
932 if ( in_array( $wordLastVowel, $frontVowels ) ) {
933 $word = implode( "", $ar ) . "нен";
934 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
935 $word = implode( "", $ar ) . "нан";
936 }
937 }
938 break;
939 case "dc51":
940 case "possessive ablative": #täweldık + şığıs
941 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $thirds ) ) {
942 if ( in_array( $wordLastVowel, $frontVowels ) ) {
943 $word = implode( "", $ar ) . "нен";
944 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
945 $word = implode( "", $ar ) . "нан";
946 }
947 } elseif ( in_array($wordEnding, $seconds ) ) {
948 if ( in_array( $wordLastVowel, $frontVowels ) ) {
949 $word = implode( "", $ar ) . "ден";
950 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
951 $word = implode( "", $ar ) . "дан";
952 }
953 }
954 break;
955 case "dc6":
956 case "comitative": #kömektes
957 if ( in_array( $wordEnding, $preConsonants ) ) {
958 $word = implode( "", $ar ) . "пен";
959 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
960 $word = implode( "", $ar ) . "мен";
961 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
962 $word = implode( "", $ar ) . "бен";
963 }
964 break;
965 case "dc61":
966 case "possessive comitative": #täweldık + kömektes
967 if ( in_array( $wordEnding, $preConsonants ) ) {
968 $word = implode( "", $ar ) . "пенен";
969 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
970 $word = implode( "", $ar ) . "менен";
971 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
972 $word = implode( "", $ar ) . "бенен";
973 }
974 break;
975 default: #dc0 #nominative #ataw
976 }
977 return $word;
978 }
979
980 function convertGrammarKk_tr( $word, $case ) {
981 global $wgGrammarForms;
982 if ( isset( $wgGrammarForms['kk-tr'][$case][$word] ) ) {
983 return $wgGrammarForms['kk-tr'][$case][$word];
984 }
985 // Set up some constants...
986 // Vowels in last syllable
987 $frontVowels = array( "e", "ö", "ü", "i", "ä", "é" );
988 $backVowels = array( "a", "o", "u", "ı" );
989 $allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" );
990 // Preceding letters
991 $preVowels = $allVowels;
992 $preNasals = array( "m", "n", "ñ" );
993 $preSonants = array( "ï", "ý", "l", "r", "w");
994 # $preVoiceds = array( "b", "v", "g", "ğ", "d", "j", "z", "h" );
995 # $preVoicelesses = array( "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç" );
996 $preConsonants = array( "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç", "b", "v", "g", "d" );
997 $preEzhZet = array( "j", "z" );
998 $preSonorants = array( "ï", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z");
999
1000 // Possessives
1001 $firsts = array( "m", "ñ" ); // 1st singular, 2nd unformal
1002 $seconds = array( "z" ); // 1st plural, 2nd formal
1003 $thirds = array( "ı", "i" ); // 3rd
1004 // Put the word in a form we can play with since we're using UTF-8
1005 $ar = array();
1006 $ar = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY);
1007 $wordEnding = $ar[count( $ar ) - 1]; //Here's the last letter in the word
1008 $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*
1009
1010 $wordLastVowel = LanguageKk_kz::lastVowel( $wordReversed, $allVowels );
1011 // Now convert the word
1012 switch ( $case ) {
1013 case "dc1":
1014 case "genitive": #ilik
1015 if ( in_array( $wordEnding, $preConsonants ) ) {
1016 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1017 $word = implode( "", $ar ) . "tiñ";
1018 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1019 $word = implode( "", $ar ) . "tıñ";
1020 }
1021 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) ) {
1022 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1023 $word = implode( "", $ar ) . "niñ";
1024 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1025 $word = implode( "", $ar ) . "nıñ";
1026 }
1027 } elseif ( in_array( $wordEnding, $preSonants ) || in_array( $wordEnding, $preEzhZet )) {
1028 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1029 $word = implode( "", $ar ) . "diñ";
1030 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1031 $word = implode( "", $ar ) . "dıñ";
1032 }
1033 }
1034 break;
1035 case "dc2":
1036 case "dative": #barıs
1037 if ( in_array( $wordEnding, $preConsonants ) ) {
1038 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1039 $word = implode( "", $ar ) . "ke";
1040 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1041 $word = implode( "", $ar ) . "qa";
1042 }
1043 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
1044 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1045 $word = implode( "", $ar ) . "ge";
1046 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1047 $word = implode( "", $ar ) . "ğa";
1048 }
1049 }
1050 break;
1051 case "dc21":
1052 case "possessive dative": #täweldık + barıs
1053 if ( in_array( $wordEnding, $firsts ) ) {
1054 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1055 $word = implode( "", $ar ) . "e";
1056 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1057 $word = implode( "", $ar ) . "a";
1058 }
1059 } elseif ( in_array( $wordEnding, $seconds ) ) {
1060 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1061 $word = implode( "", $ar ) . "ge";
1062 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1063 $word = implode( "", $ar ) . "ğa";
1064 }
1065 } elseif ( in_array( $wordEnding, $thirds ) ) {
1066 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1067 $word = implode( "", $ar ) . "ne";
1068 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1069 $word = implode( "", $ar ) . "na";
1070 }
1071 }
1072 break;
1073 case "dc3":
1074 case "accusative": #tabıs
1075 if ( in_array( $wordEnding, $preConsonants ) ) {
1076 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1077 $word = implode( "", $ar ) . "ti";
1078 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1079 $word = implode( "", $ar ) . "tı";
1080 }
1081 } elseif ( in_array( $wordEnding, $preVowels ) ) {
1082 if ( in_array($wordLastVowel, $frontVowels ) ) {
1083 $word = implode( "", $ar ) . "ni";
1084 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1085 $word = implode( "", $ar ) . "nı";
1086 }
1087 } elseif ( in_array( $wordEnding, $preSonorants) ) {
1088 if ( in_array( $wordLastVowel, $frontVowels) ) {
1089 $word = implode( "", $ar ) . "di";
1090 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1091 $word = implode( "", $ar ) . "dı";
1092 }
1093 }
1094 break;
1095 case "dc31":
1096 case "possessive accusative": #täweldık + tabıs
1097 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
1098 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1099 $word = implode( "", $ar ) . "di";
1100 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1101 $word = implode( "", $ar ) . "dı";
1102 }
1103 } elseif ( in_array( $wordEnding, $thirds ) ) {
1104 $word = implode( "", $ar ) . "n";
1105 }
1106 break;
1107 case "dc4":
1108 case "locative": #jatıs
1109 if ( in_array( $wordEnding, $preConsonants ) ) {
1110 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1111 $word = implode( "", $ar ) . "te";
1112 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1113 $word = implode( "", $ar ) . "ta";
1114 }
1115 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
1116 if ( in_array( $wordLastVowel, $frontVowels) ) {
1117 $word = implode( "", $ar ) . "de";
1118 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1119 $word = implode( "",$ar ) . "da";
1120 }
1121 }
1122 break;
1123 case "dc41":
1124 case "possessive locative": #täweldık + jatıs
1125 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
1126 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1127 $word = implode( "", $ar ) . "de";
1128 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1129 $word = implode( "", $ar ) . "da";
1130 }
1131 } elseif ( in_array( $wordEnding, $thirds ) ) {
1132 if ( in_array( $wordLastVowel, $frontVowels) ) {
1133 $word = implode( "", $ar ) . "nde";
1134 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1135 $word = implode( "",$ar ) . "nda";
1136 }
1137 }
1138 break;
1139 case "dc5":
1140 case "ablative": #şığıs
1141 if ( in_array( $wordEnding, $preConsonants ) ) {
1142 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1143 $word = implode( "", $ar ) . "ten";
1144 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1145 $word = implode( "", $ar ) . "tan";
1146 }
1147 } elseif ( in_array($wordEnding, $preVowels ) || in_array($wordEnding, $preSonants ) || in_array($wordEnding, $preEzhZet ) ) {
1148 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1149 $word = implode( "", $ar ) . "den";
1150 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1151 $word = implode( "", $ar ) . "dan";
1152 }
1153 } elseif ( in_array($wordEnding, $preNasals ) ) {
1154 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1155 $word = implode( "", $ar ) . "nen";
1156 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1157 $word = implode( "", $ar ) . "nan";
1158 }
1159 }
1160 break;
1161 case "dc51":
1162 case "possessive ablative": #täweldık + şığıs
1163 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $thirds ) ) {
1164 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1165 $word = implode( "", $ar ) . "nen";
1166 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1167 $word = implode( "", $ar ) . "nan";
1168 }
1169 } elseif ( in_array($wordEnding, $seconds ) ) {
1170 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1171 $word = implode( "", $ar ) . "den";
1172 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1173 $word = implode( "", $ar ) . "dan";
1174 }
1175 }
1176 break;
1177 case "dc6":
1178 case "comitative": #kömektes
1179 if ( in_array( $wordEnding, $preConsonants ) ) {
1180 $word = implode( "", $ar ) . "pen";
1181 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
1182 $word = implode( "", $ar ) . "men";
1183 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
1184 $word = implode( "", $ar ) . "ben";
1185 }
1186 break;
1187 case "dc61":
1188 case "possessive comitative": #täweldık + kömektes
1189 if ( in_array( $wordEnding, $preConsonants ) ) {
1190 $word = implode( "", $ar ) . "penen";
1191 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
1192 $word = implode( "", $ar ) . "menen";
1193 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
1194 $word = implode( "", $ar ) . "benen";
1195 }
1196 break;
1197 default: #dc0 #nominative #ataw
1198 }
1199 return $word;
1200 }
1201
1202 function convertGrammarKk_cn( $word, $case ) {
1203 global $wgGrammarForms;
1204 if ( isset( $wgGrammarForms['kk-cn'][$case][$word] ) ) {
1205 return $wgGrammarForms['kk-cn'][$case][$word];
1206 }
1207 // Set up some constants...
1208 // Vowels in last syllable
1209 $frontVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە" );
1210 $backVowels = array( "ا", "و", "ۇ", "ى" );
1211 $allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" );
1212 // Preceding letters
1213 $preVowels = $allVowels;
1214 $preNasals = array( "م", "ن", "ڭ" );
1215 $preSonants = array( "ي", "ي", "ل", "ر", "ۋ");
1216 # $preVoiceds = array( "ب", "ۆ", "گ", "ع", "د", "ج", "ز", "ھ" );
1217 # $preVoicelesses = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ" );
1218 $preConsonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" );
1219 $preEzhZet = array( "ج", "ز" );
1220 $preSonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز");
1221
1222 // Possessives
1223 $firsts = array( "م", "ڭ" ); // 1st singular, 2nd unformal
1224 $seconds = array( "ز" ); // 1st plural, 2nd formal
1225 $thirds = array( "ى", "ٸ" ); // 3rd
1226 // Put the word in a form we can play with since we're using UTF-8
1227 $ar = array();
1228 $ar = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY);
1229 $wordEnding = $ar[count( $ar ) - 1]; //Here's the last letter in the word
1230 $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*
1231 $wordLastVowel = LanguageKk_kz::lastVowel( $wordReversed, $allVowels );
1232 // Now convert the word
1233 switch ( $case ) {
1234 case "dc1":
1235 case "genitive": #ilik
1236 if ( in_array( $wordEnding, $preConsonants ) ) {
1237 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1238 $word = implode( "", $ar ) . "تٸڭ";
1239 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1240 $word = implode( "", $ar ) . "تىڭ";
1241 }
1242 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) ) {
1243 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1244 $word = implode( "", $ar ) . "نٸڭ";
1245 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1246 $word = implode( "", $ar ) . "نىڭ";
1247 }
1248 } elseif ( in_array( $wordEnding, $preSonants ) || in_array( $wordEnding, $preEzhZet )) {
1249 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1250 $word = implode( "", $ar ) . "دٸڭ";
1251 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1252 $word = implode( "", $ar ) . "دىڭ";
1253 }
1254 }
1255 break;
1256 case "dc2":
1257 case "dative": #barıs
1258 if ( in_array( $wordEnding, $preConsonants ) ) {
1259 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1260 $word = implode( "", $ar ) . "كە";
1261 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1262 $word = implode( "", $ar ) . "قا";
1263 }
1264 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
1265 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1266 $word = implode( "", $ar ) . "گە";
1267 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1268 $word = implode( "", $ar ) . "عا";
1269 }
1270 }
1271 break;
1272 case "dc21":
1273 case "possessive dative": #täweldık + barıs
1274 if ( in_array( $wordEnding, $firsts ) ) {
1275 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1276 $word = implode( "", $ar ) . "ە";
1277 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1278 $word = implode( "", $ar ) . "ا";
1279 }
1280 } elseif ( in_array( $wordEnding, $seconds ) ) {
1281 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1282 $word = implode( "", $ar ) . "گە";
1283 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1284 $word = implode( "", $ar ) . "عا";
1285 }
1286 } elseif ( in_array( $wordEnding, $thirds ) ) {
1287 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1288 $word = implode( "", $ar ) . "نە";
1289 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1290 $word = implode( "", $ar ) . "نا";
1291 }
1292 }
1293 break;
1294 case "dc3":
1295 case "accusative": #tabıs
1296 if ( in_array( $wordEnding, $preConsonants ) ) {
1297 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1298 $word = implode( "", $ar ) . "تٸ";
1299 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1300 $word = implode( "", $ar ) . "تى";
1301 }
1302 } elseif ( in_array( $wordEnding, $preVowels ) ) {
1303 if ( in_array($wordLastVowel, $frontVowels ) ) {
1304 $word = implode( "", $ar ) . "نٸ";
1305 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1306 $word = implode( "", $ar ) . "نى";
1307 }
1308 } elseif ( in_array( $wordEnding, $preSonorants) ) {
1309 if ( in_array( $wordLastVowel, $frontVowels) ) {
1310 $word = implode( "", $ar ) . "دٸ";
1311 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1312 $word = implode( "", $ar ) . "دى";
1313 }
1314 }
1315 break;
1316 case "dc31":
1317 case "possessive accusative": #täweldık + tabıs
1318 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
1319 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1320 $word = implode( "", $ar ) . "دٸ";
1321 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1322 $word = implode( "", $ar ) . "دى";
1323 }
1324 } elseif ( in_array( $wordEnding, $thirds ) ) {
1325 $word = implode( "", $ar ) . "ن";
1326 }
1327 break;
1328 case "dc4":
1329 case "locative": #jatıs
1330 if ( in_array( $wordEnding, $preConsonants ) ) {
1331 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1332 $word = implode( "", $ar ) . "تە";
1333 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1334 $word = implode( "", $ar ) . "تا";
1335 }
1336 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
1337 if ( in_array( $wordLastVowel, $frontVowels) ) {
1338 $word = implode( "", $ar ) . "دە";
1339 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1340 $word = implode( "",$ar ) . "دا";
1341 }
1342 }
1343 break;
1344 case "dc41":
1345 case "possessive locative": #täweldık + jatıs
1346 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
1347 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1348 $word = implode( "", $ar ) . "دە";
1349 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1350 $word = implode( "", $ar ) . "دا";
1351 }
1352 } elseif ( in_array( $wordEnding, $thirds ) ) {
1353 if ( in_array( $wordLastVowel, $frontVowels) ) {
1354 $word = implode( "", $ar ) . "ندە";
1355 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1356 $word = implode( "",$ar ) . "ندا";
1357 }
1358 }
1359 break;
1360 case "dc5":
1361 case "ablative": #şığıs
1362 if ( in_array( $wordEnding, $preConsonants ) ) {
1363 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1364 $word = implode( "", $ar ) . "تەن";
1365 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1366 $word = implode( "", $ar ) . "تان";
1367 }
1368 } elseif ( in_array($wordEnding, $preVowels ) || in_array($wordEnding, $preSonants ) || in_array($wordEnding, $preEzhZet ) ) {
1369 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1370 $word = implode( "", $ar ) . "دەن";
1371 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1372 $word = implode( "", $ar ) . "دان";
1373 }
1374 } elseif ( in_array($wordEnding, $preNasals ) ) {
1375 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1376 $word = implode( "", $ar ) . "نەن";
1377 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1378 $word = implode( "", $ar ) . "نان";
1379 }
1380 }
1381 break;
1382 case "dc51":
1383 case "possessive ablative": #täweldık + şığıs
1384 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $thirds ) ) {
1385 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1386 $word = implode( "", $ar ) . "نەن";
1387 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1388 $word = implode( "", $ar ) . "نان";
1389 }
1390 } elseif ( in_array($wordEnding, $seconds ) ) {
1391 if ( in_array( $wordLastVowel, $frontVowels ) ) {
1392 $word = implode( "", $ar ) . "دەن";
1393 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
1394 $word = implode( "", $ar ) . "دان";
1395 }
1396 }
1397 break;
1398 case "dc6":
1399 case "comitative": #kömektes
1400 if ( in_array( $wordEnding, $preConsonants ) ) {
1401 $word = implode( "", $ar ) . "پەن";
1402 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
1403 $word = implode( "", $ar ) . "مەن";
1404 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
1405 $word = implode( "", $ar ) . "بەن";
1406 }
1407 break;
1408 case "dc61":
1409 case "possessive comitative": #täweldık + kömektes
1410 if ( in_array( $wordEnding, $preConsonants ) ) {
1411 $word = implode( "", $ar ) . "پەنەن";
1412 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
1413 $word = implode( "", $ar ) . "مەنەن";
1414 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
1415 $word = implode( "", $ar ) . "بەنەن";
1416 }
1417 break;
1418 default: #dc0 #nominative #ataw
1419 }
1420 return $word;
1421 }
1422
1423 function lastVowel( $wordReversed, $allVowels ) {
1424
1425 // Find the last vowel in the word
1426 $wordLastVowel = NULL;
1427 foreach ( $wordReversed as $xvalue ) {
1428 foreach ( $allVowels as $yvalue ) {
1429 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
1430 $wordLastVowel = $xvalue;
1431 break;
1432 } else {
1433 continue;
1434 }
1435 }
1436 if ( $wordLastVowel !== NULL ) {
1437 break;
1438 } else {
1439 continue;
1440 }
1441 }
1442
1443 return $wordLastVowel; $wordEnding;
1444 }
1445
1446 /**
1447 * Avoid grouping whole numbers between 0 to 9999
1448 */
1449 function commafy( $_ ) {
1450 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
1451 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
1452 } else {
1453 return $_;
1454 }
1455 }
1456 }
1457
1458