MediaWiki master
LanguageKk_cyrl.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Languages;
8// phpcs:ignoreFile Squiz.Classes.ValidClassName.NotCamelCaps
9
13
31 protected function convertGrammarKk_cyrl( $word, $case ) {
32 $grammarForms =
34 if ( isset( $grammarForms['kk-kz'][$case][$word] ) ) {
35 return $grammarForms['kk-kz'][$case][$word];
36 }
37 if ( isset( $grammarForms['kk-cyrl'][$case][$word] ) ) {
38 return $grammarForms['kk-cyrl'][$case][$word];
39 }
40 // Set up some constants...
41 // Vowels in last syllable
42 $frontVowels = [ "е", "ө", "ү", "і", "ә", "э", "я", "ё", "и" ];
43 $backVowels = [ "а", "о", "ұ", "ы" ];
44 $allVowels = [ "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" ];
45 // Preceding letters
46 $Nasals = [ "м", "н", "ң" ];
47 $Sonants = [ "и", "й", "л", "р", "у", "ю" ];
48 $Consonants = [ "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" ];
49 $Sibilants = [ "ж", "з" ];
50 $Sonorants = [ "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" ];
51
52 // Possessives
53 $firstPerson = [ "м", "ң" ]; // 1st singular, 2nd informal
54 $secondPerson = [ "з" ]; // 1st plural, 2nd formal
55 $thirdPerson = [ "ы", "і" ]; // 3rd
56
57 [ $wordEnding, $wordLastVowel ] = $this->lastLetter( $word, $allVowels );
58
59 // Now convert the word
60 switch ( $case ) {
61 case "dc1":
62 case "genitive": # ilik
63 if ( in_array( $wordEnding, $Consonants ) ) {
64 if ( in_array( $wordLastVowel, $frontVowels ) ) {
65 $word .= "тің";
66 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
67 $word .= "тың";
68 }
69 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
70 if ( in_array( $wordLastVowel, $frontVowels ) ) {
71 $word .= "нің";
72 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
73 $word .= "ның";
74 }
75 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
76 if ( in_array( $wordLastVowel, $frontVowels ) ) {
77 $word .= "дің";
78 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
79 $word .= "дың";
80 }
81 }
82 break;
83
84 case "dc2":
85 case "dative": # barıs
86 if ( in_array( $wordEnding, $Consonants ) ) {
87 if ( in_array( $wordLastVowel, $frontVowels ) ) {
88 $word .= "ке";
89 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
90 $word .= "қа";
91 }
92 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
93 if ( in_array( $wordLastVowel, $frontVowels ) ) {
94 $word .= "ге";
95 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
96 $word .= "ға";
97 }
98 }
99 break;
100
101 case "dc21":
102 case "possessive dative": # täweldık + barıs
103 if ( in_array( $wordEnding, $firstPerson ) ) {
104 if ( in_array( $wordLastVowel, $frontVowels ) ) {
105 $word .= "е";
106 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
107 $word .= "а";
108 }
109 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
110 if ( in_array( $wordLastVowel, $frontVowels ) ) {
111 $word .= "ге";
112 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
113 $word .= "ға";
114 }
115 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
116 if ( in_array( $wordLastVowel, $frontVowels ) ) {
117 $word .= "не";
118 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
119 $word .= "на";
120 }
121 }
122 break;
123
124 case "dc3":
125 case "accusative": # tabıs
126 if ( in_array( $wordEnding, $Consonants ) ) {
127 if ( in_array( $wordLastVowel, $frontVowels ) ) {
128 $word .= "ті";
129 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
130 $word .= "ты";
131 }
132 } elseif ( in_array( $wordEnding, $allVowels ) ) {
133 if ( in_array( $wordLastVowel, $frontVowels ) ) {
134 $word .= "ні";
135 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
136 $word .= "ны";
137 }
138 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
139 if ( in_array( $wordLastVowel, $frontVowels ) ) {
140 $word .= "ді";
141 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
142 $word .= "ды";
143 }
144 }
145 break;
146
147 case "dc31":
148 case "possessive accusative": # täweldık + tabıs
149 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
150 if ( in_array( $wordLastVowel, $frontVowels ) ) {
151 $word .= "ді";
152 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
153 $word .= "ды";
154 }
155 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
156 $word .= "н";
157 }
158 break;
159
160 case "dc4":
161 case "locative": # jatıs
162 if ( in_array( $wordEnding, $Consonants ) ) {
163 if ( in_array( $wordLastVowel, $frontVowels ) ) {
164 $word .= "те";
165 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
166 $word .= "та";
167 }
168 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
169 if ( in_array( $wordLastVowel, $frontVowels ) ) {
170 $word .= "де";
171 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
172 $word .= "да";
173 }
174 }
175 break;
176
177 case "dc41":
178 case "possessive locative": # täweldık + jatıs
179 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
180 if ( in_array( $wordLastVowel, $frontVowels ) ) {
181 $word .= "де";
182 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
183 $word .= "да";
184 }
185 } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
186 if ( in_array( $wordLastVowel, $frontVowels ) ) {
187 $word .= "нде";
188 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
189 $word .= "нда";
190 }
191 }
192 break;
193
194 case "dc5":
195 case "ablative": # şığıs
196 if ( in_array( $wordEnding, $Consonants ) ) {
197 if ( in_array( $wordLastVowel, $frontVowels ) ) {
198 $word .= "тен";
199 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
200 $word .= "тан";
201 }
202 } elseif ( in_array( $wordEnding, $allVowels )
203 || in_array( $wordEnding, $Sonants )
204 || in_array( $wordEnding, $Sibilants )
205 ) {
206 if ( in_array( $wordLastVowel, $frontVowels ) ) {
207 $word .= "ден";
208 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
209 $word .= "дан";
210 }
211 } elseif ( in_array( $wordEnding, $Nasals ) ) {
212 if ( in_array( $wordLastVowel, $frontVowels ) ) {
213 $word .= "нен";
214 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
215 $word .= "нан";
216 }
217 }
218 break;
219
220 case "dc51":
221 case "possessive ablative": # täweldık + şığıs
222 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
223 if ( in_array( $wordLastVowel, $frontVowels ) ) {
224 $word .= "нен";
225 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
226 $word .= "нан";
227 }
228 } elseif ( in_array( $wordEnding, $secondPerson ) ) {
229 if ( in_array( $wordLastVowel, $frontVowels ) ) {
230 $word .= "ден";
231 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
232 $word .= "дан";
233 }
234 }
235 break;
236
237 case "dc6":
238 case "comitative": # kömektes
239 if ( in_array( $wordEnding, $Consonants ) ) {
240 $word .= "пен";
241 } elseif ( in_array( $wordEnding, $allVowels )
242 || in_array( $wordEnding, $Nasals )
243 || in_array( $wordEnding, $Sonants )
244 ) {
245 $word .= "мен";
246 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
247 $word .= "бен";
248 }
249 break;
250 case "dc61":
251 case "possessive comitative": # täweldık + kömektes
252 if ( in_array( $wordEnding, $Consonants ) ) {
253 $word .= "пенен";
254 } elseif ( in_array( $wordEnding, $allVowels )
255 || in_array( $wordEnding, $Nasals )
256 || in_array( $wordEnding, $Sonants )
257 ) {
258 $word .= "менен";
259 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
260 $word .= "бенен";
261 }
262 break;
263
264 default: # dc0 #nominative #ataw
265 break;
266 }
267 return $word;
268 }
269
275 private function lastLetter( $word, $allVowels ) {
276 // Put the word in a form we can play with since we're using UTF-8
277 $ar = mb_str_split( $this->lc( $word ), 1 );
278
279 // Here's the last letter in the word
280 $lastLetter = end( $ar );
281
282 // Find the last vowel in the word
283 for ( $i = count( $ar ); $i--; ) {
284 $lastVowel = $ar[$i];
285 if ( in_array( $lastVowel, $allVowels, true ) ) {
286 return [ $lastLetter, $lastVowel ];
287 }
288 }
289
290 return [ $lastLetter, null ];
291 }
292}
293
294
296class_alias( LanguageKk_cyrl::class, 'LanguageKk_cyrl' );
Base class for language-specific code.
Definition Language.php:69
lc( $str, $first=false)
convertGrammarKk_cyrl( $word, $case)
Convert from the nominative form of a noun to some other case Invoked with {{GRAMMAR:case|word}}.
A class containing constants representing the names of configuration variables.
const GrammarForms
Name constant for the GrammarForms setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.