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