| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
use MediaWiki\MainConfigNames; |
| 23 |
use MediaWiki\MediaWikiServices; |
| 24 |
use MediaWiki\Language\Language; |
| 25 |
|
| 26 |
|
| 27 |
қша) |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
class LanguageKk_cyrl extends Language { |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
protected function convertGrammarKk_cyrl( $word, $case ) { |
| 44 |
$grammarForms = |
| 45 |
MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms ); |
| 46 |
if ( isset( $grammarForms['kk-kz'][$case][$word] ) ) { |
| 47 |
return $grammarForms['kk-kz'][$case][$word]; |
| 48 |
} |
| 49 |
if ( isset( $grammarForms['kk-cyrl'][$case][$word] ) ) { |
| 50 |
return $grammarForms['kk-cyrl'][$case][$word]; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
$frontVowels = [ "е", "ө", "ү", "і", "ә", "э", "я", "ё", "и" ]; |
| 55 |
$backVowels = [ "а", "о", "ұ", "ы" ]; |
| 56 |
$allVowels = [ "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" ]; |
| 57 |
|
| 58 |
$Nasals = [ "м", "н", "ң" ]; |
| 59 |
$Sonants = [ "и", "й", "л", "р", "у", "ю" ]; |
| 60 |
$Consonants = [ "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" ]; |
| 61 |
$Sibilants = [ "ж", "з" ]; |
| 62 |
$Sonorants = [ "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" ]; |
| 63 |
|
| 64 |
|
| 65 |
$firstPerson = [ "м", "ң" ]al |
| 66 |
$secondPerson = [ "з" ];l |
| 67 |
$thirdPerson = [ "ы", "і" ]rd |
| 68 |
|
| 69 |
[ $wordEnding, $wordLastVowel ] = $this->lastLetter( $word, $allVowels ); |
| 70 |
|
| 71 |
|
| 72 |
switch ( $case ) { |
| 73 |
case "dc1": |
| 74 |
case "genitive": |
| 75 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 76 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 77 |
$word .= "тің"; |
| 78 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 79 |
$word .= "тың"; |
| 80 |
} |
| 81 |
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) { |
| 82 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 83 |
$word .= "нің"; |
| 84 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 85 |
$word .= "ның"; |
| 86 |
} |
| 87 |
} elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) { |
| 88 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 89 |
$word .= "дің"; |
| 90 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 91 |
$word .= "дың"; |
| 92 |
} |
| 93 |
} |
| 94 |
break; |
| 95 |
|
| 96 |
case "dc2": |
| 97 |
case "dative": s |
| 98 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 99 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 100 |
$word .= "ке"; |
| 101 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 102 |
$word .= "қа"; |
| 103 |
} |
| 104 |
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) { |
| 105 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 106 |
$word .= "ге"; |
| 107 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 108 |
$word .= "ға"; |
| 109 |
} |
| 110 |
} |
| 111 |
break; |
| 112 |
|
| 113 |
case "dc21": |
| 114 |
case "possessive dative": ıs |
| 115 |
if ( in_array( $wordEnding, $firstPerson ) ) { |
| 116 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 117 |
$word .= "е"; |
| 118 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 119 |
$word .= "а"; |
| 120 |
} |
| 121 |
} elseif ( in_array( $wordEnding, $secondPerson ) ) { |
| 122 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 123 |
$word .= "ге"; |
| 124 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 125 |
$word .= "ға"; |
| 126 |
} |
| 127 |
} elseif ( in_array( $wordEnding, $thirdPerson ) ) { |
| 128 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 129 |
$word .= "не"; |
| 130 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 131 |
$word .= "на"; |
| 132 |
} |
| 133 |
} |
| 134 |
break; |
| 135 |
|
| 136 |
case "dc3": |
| 137 |
case "accusative": s |
| 138 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 139 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 140 |
$word .= "ті"; |
| 141 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 142 |
$word .= "ты"; |
| 143 |
} |
| 144 |
} elseif ( in_array( $wordEnding, $allVowels ) ) { |
| 145 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 146 |
$word .= "ні"; |
| 147 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 148 |
$word .= "ны"; |
| 149 |
} |
| 150 |
} elseif ( in_array( $wordEnding, $Sonorants ) ) { |
| 151 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 152 |
$word .= "ді"; |
| 153 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 154 |
$word .= "ды"; |
| 155 |
} |
| 156 |
} |
| 157 |
break; |
| 158 |
|
| 159 |
case "dc31": |
| 160 |
case "possessive accusative": ıs |
| 161 |
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) { |
| 162 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 163 |
$word .= "ді"; |
| 164 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 165 |
$word .= "ды"; |
| 166 |
} |
| 167 |
} elseif ( in_array( $wordEnding, $thirdPerson ) ) { |
| 168 |
$word .= "н"; |
| 169 |
} |
| 170 |
break; |
| 171 |
|
| 172 |
case "dc4": |
| 173 |
case "locative": s |
| 174 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 175 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 176 |
$word .= "те"; |
| 177 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 178 |
$word .= "та"; |
| 179 |
} |
| 180 |
} elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) { |
| 181 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 182 |
$word .= "де"; |
| 183 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 184 |
$word .= "да"; |
| 185 |
} |
| 186 |
} |
| 187 |
break; |
| 188 |
|
| 189 |
case "dc41": |
| 190 |
case "possessive locative": ıs |
| 191 |
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) { |
| 192 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 193 |
$word .= "де"; |
| 194 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 195 |
$word .= "да"; |
| 196 |
} |
| 197 |
} elseif ( in_array( $wordEnding, $thirdPerson ) ) { |
| 198 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 199 |
$word .= "нде"; |
| 200 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 201 |
$word .= "нда"; |
| 202 |
} |
| 203 |
} |
| 204 |
break; |
| 205 |
|
| 206 |
case "dc5": |
| 207 |
case "ablative": ğıs |
| 208 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 209 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 210 |
$word .= "тен"; |
| 211 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 212 |
$word .= "тан"; |
| 213 |
} |
| 214 |
} elseif ( in_array( $wordEnding, $allVowels ) |
| 215 |
|| in_array( $wordEnding, $Sonants ) |
| 216 |
|| in_array( $wordEnding, $Sibilants ) |
| 217 |
) { |
| 218 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 219 |
$word .= "ден"; |
| 220 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 221 |
$word .= "дан"; |
| 222 |
} |
| 223 |
} elseif ( in_array( $wordEnding, $Nasals ) ) { |
| 224 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 225 |
$word .= "нен"; |
| 226 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 227 |
$word .= "нан"; |
| 228 |
} |
| 229 |
} |
| 230 |
break; |
| 231 |
|
| 232 |
case "dc51": |
| 233 |
case "possessive ablative": ığıs |
| 234 |
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) { |
| 235 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 236 |
$word .= "нен"; |
| 237 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 238 |
$word .= "нан"; |
| 239 |
} |
| 240 |
} elseif ( in_array( $wordEnding, $secondPerson ) ) { |
| 241 |
if ( in_array( $wordLastVowel, $frontVowels ) ) { |
| 242 |
$word .= "ден"; |
| 243 |
} elseif ( in_array( $wordLastVowel, $backVowels ) ) { |
| 244 |
$word .= "дан"; |
| 245 |
} |
| 246 |
} |
| 247 |
break; |
| 248 |
|
| 249 |
case "dc6": |
| 250 |
case "comitative": s |
| 251 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 252 |
$word .= "пен"; |
| 253 |
} elseif ( in_array( $wordEnding, $allVowels ) |
| 254 |
|| in_array( $wordEnding, $Nasals ) |
| 255 |
|| in_array( $wordEnding, $Sonants ) |
| 256 |
) { |
| 257 |
$word .= "мен"; |
| 258 |
} elseif ( in_array( $wordEnding, $Sibilants ) ) { |
| 259 |
$word .= "бен"; |
| 260 |
} |
| 261 |
break; |
| 262 |
case "dc61": |
| 263 |
case "possessive comitative": tes |
| 264 |
if ( in_array( $wordEnding, $Consonants ) ) { |
| 265 |
$word .= "пенен"; |
| 266 |
} elseif ( in_array( $wordEnding, $allVowels ) |
| 267 |
|| in_array( $wordEnding, $Nasals ) |
| 268 |
|| in_array( $wordEnding, $Sonants ) |
| 269 |
) { |
| 270 |
$word .= "менен"; |
| 271 |
} elseif ( in_array( $wordEnding, $Sibilants ) ) { |
| 272 |
$word .= "бенен"; |
| 273 |
} |
| 274 |
break; |
| 275 |
|
| 276 |
default: |
| 277 |
break; |
| 278 |
} |
| 279 |
return $word; |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
private function lastLetter( $word, $allVowels ) { |
| 288 |
|
| 289 |
$ar = mb_str_split( $this->lc( $word ), 1 ); |
| 290 |
|
| 291 |
|
| 292 |
$lastLetter = end( $ar ); |
| 293 |
|
| 294 |
|
| 295 |
for ( $i = count( $ar ); $i--; ) { |
| 296 |
$lastVowel = $ar[$i]; |
| 297 |
if ( in_array( $lastVowel, $allVowels, true ) ) { |
| 298 |
return [ $lastLetter, $lastVowel ]; |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
return [ $lastLetter, null ]; |
| 303 |
} |
| 304 |
} |