10 class LanguageKk_kz
extends Language
{
12 # Convert from the nominative form of a noun to some other case
13 # Invoked with {{GRAMMAR:case|word}}
15 * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
17 function convertGrammar( $word, $case ) {
18 global $wgGrammarForms;
19 if ( isset( $wgGrammarForms['kk'][$case][$word] ) ) {
20 return $wgGrammarForms['kk'][$case][$word];
22 // Set up some constants...
23 // Vowels in last syllable
24 $frontVowels = array( "е", "ө", "ү", "і", "ә", "э" );
25 $backVowels = array( "а", "о", "ұ", "ы", "я", "ё" );
26 $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё" );
28 $preVowels = $allVowels;
29 $preNasals = array( "м", "н", "ң" );
30 $preSonants = array( "и", "й", "л", "р", "у", "ю");
31 # $preVoiceds = array( "б", "в", "г", "ғ", "д", "ж", "з", "һ" );
32 # $preVoicelesses = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ" );
33 $preConsonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
34 $preEzhZet = array( "ж", "з" );
35 $preSonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з");
38 $firsts = array( "м", "ң" ); // 1st singular, 2nd unformal
39 $seconds = array( "з" ); // 1st plural, 2nd formal
40 $thirds = array( "ы", "і" ); // 3rd
42 // Put the word in a form we can play with since we're using UTF-8
44 $ar = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY
);
45 $wordEnding = $ar[count( $ar ) - 1]; //Here's the last letter in the word
46 $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*
48 // Find the last vowel in the word
49 $wordLastVowel = NULL;
50 foreach ( $wordReversed as $xvalue ) {
51 foreach ( $allVowels as $yvalue ) {
52 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
53 $wordLastVowel = $xvalue;
59 if ( $wordLastVowel !== NULL ) {
66 // Now convert the word
69 case "genitive": #ilik
70 if ( in_array( $wordEnding, $preConsonants ) ) {
71 if ( in_array( $wordLastVowel, $frontVowels ) ) {
72 $word = implode( "", $ar ) . "тің";
73 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
74 $word = implode( "", $ar ) . "тың";
76 } elseif ( in_array( $wordEnding, $preVowels ) ||
in_array( $wordEnding, $preNasals ) ) {
77 if ( in_array( $wordLastVowel, $frontVowels ) ) {
78 $word = implode( "", $ar ) . "нің";
79 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
80 $word = implode( "", $ar ) . "ның";
82 } elseif ( in_array( $wordEnding, $preSonants ) ||
in_array( $wordEnding, $preEzhZet )) {
83 if ( in_array( $wordLastVowel, $frontVowels ) ) {
84 $word = implode( "", $ar ) . "дің";
85 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
86 $word = implode( "", $ar ) . "дың";
92 if ( in_array( $wordEnding, $preConsonants ) ) {
93 if ( in_array( $wordLastVowel, $frontVowels ) ) {
94 $word = implode( "", $ar ) . "ке";
95 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
96 $word = implode( "", $ar ) . "қа";
98 } elseif ( in_array( $wordEnding, $preVowels ) ||
in_array( $wordEnding, $preSonorants ) ) {
99 if ( in_array( $wordLastVowel, $frontVowels ) ) {
100 $word = implode( "", $ar ) . "ге";
101 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
102 $word = implode( "", $ar ) . "ға";
107 case "possessive dative": #täweldık + barıs
108 if ( in_array( $wordEnding, $firsts ) ) {
109 if ( in_array( $wordLastVowel, $frontVowels ) ) {
110 $word = implode( "", $ar ) . "е";
111 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
112 $word = implode( "", $ar ) . "а";
114 } elseif ( in_array( $wordEnding, $seconds ) ) {
115 if ( in_array( $wordLastVowel, $frontVowels ) ) {
116 $word = implode( "", $ar ) . "ге";
117 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
118 $word = implode( "", $ar ) . "ға";
120 } elseif ( in_array( $wordEnding, $thirds ) ) {
121 if ( in_array( $wordLastVowel, $frontVowels ) ) {
122 $word = implode( "", $ar ) . "не";
123 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
124 $word = implode( "", $ar ) . "на";
129 case "accusative": #tabıs
130 if ( in_array( $wordEnding, $preConsonants ) ) {
131 if ( in_array( $wordLastVowel, $frontVowels ) ) {
132 $word = implode( "", $ar ) . "ті";
133 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
134 $word = implode( "", $ar ) . "ты";
136 } elseif ( in_array( $wordEnding, $preVowels ) ) {
137 if ( in_array($wordLastVowel, $frontVowels ) ) {
138 $word = implode( "", $ar ) . "ні";
139 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
140 $word = implode( "", $ar ) . "ны";
142 } elseif ( in_array( $wordEnding, $preSonorants) ) {
143 if ( in_array( $wordLastVowel, $frontVowels) ) {
144 $word = implode( "", $ar ) . "ді";
145 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
146 $word = implode( "", $ar ) . "ды";
151 case "possessive accusative": #täweldık + tabıs
152 if ( in_array( $wordEnding, $firsts ) ||
in_array( $wordEnding, $seconds ) ) {
153 if ( in_array( $wordLastVowel, $frontVowels ) ) {
154 $word = implode( "", $ar ) . "ді";
155 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
156 $word = implode( "", $ar ) . "ды";
158 } elseif ( in_array( $wordEnding, $thirds ) ) {
159 $word = implode( "", $ar ) . "н";
163 case "locative": #jatıs
164 if ( in_array( $wordEnding, $preConsonants ) ) {
165 if ( in_array( $wordLastVowel, $frontVowels ) ) {
166 $word = implode( "", $ar ) . "те";
167 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
168 $word = implode( "", $ar ) . "та";
170 } elseif ( in_array( $wordEnding, $preVowels ) ||
in_array( $wordEnding, $preSonorants ) ) {
171 if ( in_array( $wordLastVowel, $frontVowels) ) {
172 $word = implode( "", $ar ) . "де";
173 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
174 $word = implode( "",$ar ) . "да";
179 case "possessive locative": #täweldık + jatıs
180 if ( in_array( $wordEnding, $firsts ) ||
in_array( $wordEnding, $seconds ) ) {
181 if ( in_array( $wordLastVowel, $frontVowels ) ) {
182 $word = implode( "", $ar ) . "де";
183 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
184 $word = implode( "", $ar ) . "да";
186 } elseif ( in_array( $wordEnding, $thirds ) ) {
187 if ( in_array( $wordLastVowel, $frontVowels) ) {
188 $word = implode( "", $ar ) . "нде";
189 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
190 $word = implode( "",$ar ) . "нда";
195 case "ablative": #şığıs
196 if ( in_array( $wordEnding, $preConsonants ) ) {
197 if ( in_array( $wordLastVowel, $frontVowels ) ) {
198 $word = implode( "", $ar ) . "тен";
199 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
200 $word = implode( "", $ar ) . "тан";
202 } elseif ( in_array($wordEnding, $preVowels ) ||
in_array($wordEnding, $preSonants ) ||
in_array($wordEnding, $preEzhZet ) ) {
203 if ( in_array( $wordLastVowel, $frontVowels ) ) {
204 $word = implode( "", $ar ) . "ден";
205 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
206 $word = implode( "", $ar ) . "дан";
208 } elseif ( in_array($wordEnding, $preNasals ) ) {
209 if ( in_array( $wordLastVowel, $frontVowels ) ) {
210 $word = implode( "", $ar ) . "нен";
211 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
212 $word = implode( "", $ar ) . "нан";
217 case "possessive ablative": #täweldık + şığıs
218 if ( in_array( $wordEnding, $firsts ) ||
in_array( $wordEnding, $thirds ) ) {
219 if ( in_array( $wordLastVowel, $frontVowels ) ) {
220 $word = implode( "", $ar ) . "нен";
221 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
222 $word = implode( "", $ar ) . "нан";
224 } elseif ( in_array($wordEnding, $seconds ) ) {
225 if ( in_array( $wordLastVowel, $frontVowels ) ) {
226 $word = implode( "", $ar ) . "ден";
227 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
228 $word = implode( "", $ar ) . "дан";
233 case "comitative": #kömektes
234 if ( in_array( $wordEnding, $preConsonants ) ) {
235 $word = implode( "", $ar ) . "пен";
236 } elseif ( in_array( $wordEnding, $preVowels ) ||
in_array( $wordEnding, $preNasals ) ||
in_array( $wordEnding, $preSonants ) ) {
237 $word = implode( "", $ar ) . "мен";
238 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
239 $word = implode( "", $ar ) . "бен";
243 case "possessive comitative": #täweldık + kömektes
244 if ( in_array( $wordEnding, $preConsonants ) ) {
245 $word = implode( "", $ar ) . "пенен";
246 } elseif ( in_array( $wordEnding, $preVowels ) ||
in_array( $wordEnding, $preNasals ) ||
in_array( $wordEnding, $preSonants ) ) {
247 $word = implode( "", $ar ) . "менен";
248 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
249 $word = implode( "", $ar ) . "бенен";
252 default: #dc0 #nominative #ataw
258 * Avoid grouping whole numbers between 0 to 9999
260 function commafy( $_ ) {
261 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
262 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );