LanguageKk_cyrl.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. <?php
  2. /**
  3. * Kazakh (Қазақша) specific code.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup Language
  22. */
  23. /**
  24. * Kazakh (Қазақша)
  25. *
  26. * @ingroup Language
  27. */
  28. // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
  29. class LanguageKk_cyrl extends Language {
  30. # Convert from the nominative form of a noun to some other case
  31. # Invoked with {{GRAMMAR:case|word}}
  32. /**
  33. * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
  34. *
  35. * @param string $word
  36. * @param string $case
  37. *
  38. * @return string
  39. */
  40. function convertGrammarKk_cyrl( $word, $case ) {
  41. global $wgGrammarForms;
  42. if ( isset( $wgGrammarForms['kk-kz'][$case][$word] ) ) {
  43. return $wgGrammarForms['kk-kz'][$case][$word];
  44. }
  45. if ( isset( $wgGrammarForms['kk-cyrl'][$case][$word] ) ) {
  46. return $wgGrammarForms['kk-cyrl'][$case][$word];
  47. }
  48. // Set up some constants...
  49. // Vowels in last syllable
  50. $frontVowels = [ "е", "ө", "ү", "і", "ә", "э", "я", "ё", "и" ];
  51. $backVowels = [ "а", "о", "ұ", "ы" ];
  52. $allVowels = [ "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" ];
  53. // Preceding letters
  54. $Nasals = [ "м", "н", "ң" ];
  55. $Sonants = [ "и", "й", "л", "р", "у", "ю" ];
  56. $Consonants = [ "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" ];
  57. $Sibilants = [ "ж", "з" ];
  58. $Sonorants = [ "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" ];
  59. // Possessives
  60. $firstPerson = [ "м", "ң" ]; // 1st singular, 2nd unformal
  61. $secondPerson = [ "з" ]; // 1st plural, 2nd formal
  62. $thirdPerson = [ "ы", "і" ]; // 3rd
  63. $lastLetter = $this->lastLetter( $word, $allVowels );
  64. $wordEnding =& $lastLetter[0];
  65. $wordLastVowel =& $lastLetter[1];
  66. // Now convert the word
  67. switch ( $case ) {
  68. case "dc1":
  69. case "genitive": # ilik
  70. if ( in_array( $wordEnding, $Consonants ) ) {
  71. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  72. $word = $word . "тің";
  73. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  74. $word = $word . "тың";
  75. }
  76. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
  77. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  78. $word = $word . "нің";
  79. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  80. $word = $word . "ның";
  81. }
  82. } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
  83. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  84. $word = $word . "дің";
  85. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  86. $word = $word . "дың";
  87. }
  88. }
  89. break;
  90. case "dc2":
  91. case "dative": # barıs
  92. if ( in_array( $wordEnding, $Consonants ) ) {
  93. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  94. $word = $word . "ке";
  95. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  96. $word = $word . "қа";
  97. }
  98. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
  99. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  100. $word = $word . "ге";
  101. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  102. $word = $word . "ға";
  103. }
  104. }
  105. break;
  106. case "dc21":
  107. case "possessive dative": # täweldık + barıs
  108. if ( in_array( $wordEnding, $firstPerson ) ) {
  109. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  110. $word = $word . "е";
  111. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  112. $word = $word . "а";
  113. }
  114. } elseif ( in_array( $wordEnding, $secondPerson ) ) {
  115. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  116. $word = $word . "ге";
  117. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  118. $word = $word . "ға";
  119. }
  120. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  121. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  122. $word = $word . "не";
  123. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  124. $word = $word . "на";
  125. }
  126. }
  127. break;
  128. case "dc3":
  129. case "accusative": # tabıs
  130. if ( in_array( $wordEnding, $Consonants ) ) {
  131. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  132. $word = $word . "ті";
  133. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  134. $word = $word . "ты";
  135. }
  136. } elseif ( in_array( $wordEnding, $allVowels ) ) {
  137. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  138. $word = $word . "ні";
  139. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  140. $word = $word . "ны";
  141. }
  142. } elseif ( in_array( $wordEnding, $Sonorants ) ) {
  143. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  144. $word = $word . "ді";
  145. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  146. $word = $word . "ды";
  147. }
  148. }
  149. break;
  150. case "dc31":
  151. case "possessive accusative": # täweldık + tabıs
  152. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
  153. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  154. $word = $word . "ді";
  155. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  156. $word = $word . "ды";
  157. }
  158. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  159. $word = $word . "н";
  160. }
  161. break;
  162. case "dc4":
  163. case "locative": # jatıs
  164. if ( in_array( $wordEnding, $Consonants ) ) {
  165. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  166. $word = $word . "те";
  167. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  168. $word = $word . "та";
  169. }
  170. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
  171. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  172. $word = $word . "де";
  173. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  174. $word = $word . "да";
  175. }
  176. }
  177. break;
  178. case "dc41":
  179. case "possessive locative": # täweldık + jatıs
  180. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
  181. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  182. $word = $word . "де";
  183. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  184. $word = $word . "да";
  185. }
  186. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  187. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  188. $word = $word . "нде";
  189. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  190. $word = $word . "нда";
  191. }
  192. }
  193. break;
  194. case "dc5":
  195. case "ablative": # şığıs
  196. if ( in_array( $wordEnding, $Consonants ) ) {
  197. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  198. $word = $word . "тен";
  199. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  200. $word = $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 = $word . "ден";
  208. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  209. $word = $word . "дан";
  210. }
  211. } elseif ( in_array( $wordEnding, $Nasals ) ) {
  212. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  213. $word = $word . "нен";
  214. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  215. $word = $word . "нан";
  216. }
  217. }
  218. break;
  219. case "dc51":
  220. case "possessive ablative": # täweldık + şığıs
  221. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
  222. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  223. $word = $word . "нен";
  224. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  225. $word = $word . "нан";
  226. }
  227. } elseif ( in_array( $wordEnding, $secondPerson ) ) {
  228. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  229. $word = $word . "ден";
  230. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  231. $word = $word . "дан";
  232. }
  233. }
  234. break;
  235. case "dc6":
  236. case "comitative": # kömektes
  237. if ( in_array( $wordEnding, $Consonants ) ) {
  238. $word = $word . "пен";
  239. } elseif ( in_array( $wordEnding, $allVowels )
  240. || in_array( $wordEnding, $Nasals )
  241. || in_array( $wordEnding, $Sonants )
  242. ) {
  243. $word = $word . "мен";
  244. } elseif ( in_array( $wordEnding, $Sibilants ) ) {
  245. $word = $word . "бен";
  246. }
  247. break;
  248. case "dc61":
  249. case "possessive comitative": # täweldık + kömektes
  250. if ( in_array( $wordEnding, $Consonants ) ) {
  251. $word = $word . "пенен";
  252. } elseif ( in_array( $wordEnding, $allVowels )
  253. || in_array( $wordEnding, $Nasals )
  254. || in_array( $wordEnding, $Sonants )
  255. ) {
  256. $word = $word . "менен";
  257. } elseif ( in_array( $wordEnding, $Sibilants ) ) {
  258. $word = $word . "бенен";
  259. }
  260. break;
  261. default: # dc0 #nominative #ataw
  262. }
  263. return $word;
  264. }
  265. /**
  266. * @param string $word
  267. * @param string $case
  268. * @return string
  269. */
  270. function convertGrammarKk_latn( $word, $case ) {
  271. global $wgGrammarForms;
  272. if ( isset( $wgGrammarForms['kk-tr'][$case][$word] ) ) {
  273. return $wgGrammarForms['kk-tr'][$case][$word];
  274. }
  275. if ( isset( $wgGrammarForms['kk-latn'][$case][$word] ) ) {
  276. return $wgGrammarForms['kk-latn'][$case][$word];
  277. }
  278. // Set up some constants...
  279. // Vowels in last syllable
  280. $frontVowels = [ "e", "ö", "ü", "i", "ä", "é" ];
  281. $backVowels = [ "a", "o", "u", "ı" ];
  282. $allVowels = [ "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" ];
  283. // Preceding letters
  284. $Nasals = [ "m", "n", "ñ" ];
  285. $Sonants = [ "ï", "y", "ý", "l", "r", "w" ];
  286. $Consonants = [ "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç", "b", "v", "g", "d" ];
  287. $Sibilants = [ "j", "z" ];
  288. $Sonorants = [ "ï", "y", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z" ];
  289. // Possessives
  290. $firstPerson = [ "m", "ñ" ]; // 1st singular, 2nd unformal
  291. $secondPerson = [ "z" ]; // 1st plural, 2nd formal
  292. $thirdPerson = [ "ı", "i" ]; // 3rd
  293. $lastLetter = $this->lastLetter( $word, $allVowels );
  294. $wordEnding =& $lastLetter[0];
  295. $wordLastVowel =& $lastLetter[1];
  296. // Now convert the word
  297. switch ( $case ) {
  298. case "dc1":
  299. case "genitive": # ilik
  300. if ( in_array( $wordEnding, $Consonants ) ) {
  301. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  302. $word = $word . "tiñ";
  303. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  304. $word = $word . "tıñ";
  305. }
  306. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
  307. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  308. $word = $word . "niñ";
  309. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  310. $word = $word . "nıñ";
  311. }
  312. } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
  313. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  314. $word = $word . "diñ";
  315. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  316. $word = $word . "dıñ";
  317. }
  318. }
  319. break;
  320. case "dc2":
  321. case "dative": # barıs
  322. if ( in_array( $wordEnding, $Consonants ) ) {
  323. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  324. $word = $word . "ke";
  325. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  326. $word = $word . "qa";
  327. }
  328. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
  329. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  330. $word = $word . "ge";
  331. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  332. $word = $word . "ğa";
  333. }
  334. }
  335. break;
  336. case "dc21":
  337. case "possessive dative": # täweldık + barıs
  338. if ( in_array( $wordEnding, $firstPerson ) ) {
  339. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  340. $word = $word . "e";
  341. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  342. $word = $word . "a";
  343. }
  344. } elseif ( in_array( $wordEnding, $secondPerson ) ) {
  345. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  346. $word = $word . "ge";
  347. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  348. $word = $word . "ğa";
  349. }
  350. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  351. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  352. $word = $word . "ne";
  353. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  354. $word = $word . "na";
  355. }
  356. }
  357. break;
  358. case "dc3":
  359. case "accusative": # tabıs
  360. if ( in_array( $wordEnding, $Consonants ) ) {
  361. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  362. $word = $word . "ti";
  363. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  364. $word = $word . "tı";
  365. }
  366. } elseif ( in_array( $wordEnding, $allVowels ) ) {
  367. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  368. $word = $word . "ni";
  369. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  370. $word = $word . "nı";
  371. }
  372. } elseif ( in_array( $wordEnding, $Sonorants ) ) {
  373. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  374. $word = $word . "di";
  375. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  376. $word = $word . "dı";
  377. }
  378. }
  379. break;
  380. case "dc31":
  381. case "possessive accusative": # täweldık + tabıs
  382. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
  383. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  384. $word = $word . "di";
  385. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  386. $word = $word . "dı";
  387. }
  388. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  389. $word = $word . "n";
  390. }
  391. break;
  392. case "dc4":
  393. case "locative": # jatıs
  394. if ( in_array( $wordEnding, $Consonants ) ) {
  395. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  396. $word = $word . "te";
  397. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  398. $word = $word . "ta";
  399. }
  400. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
  401. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  402. $word = $word . "de";
  403. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  404. $word = $word . "da";
  405. }
  406. }
  407. break;
  408. case "dc41":
  409. case "possessive locative": # täweldık + jatıs
  410. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
  411. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  412. $word = $word . "de";
  413. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  414. $word = $word . "da";
  415. }
  416. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  417. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  418. $word = $word . "nde";
  419. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  420. $word = $word . "nda";
  421. }
  422. }
  423. break;
  424. case "dc5":
  425. case "ablative": # şığıs
  426. if ( in_array( $wordEnding, $Consonants ) ) {
  427. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  428. $word = $word . "ten";
  429. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  430. $word = $word . "tan";
  431. }
  432. } elseif ( in_array( $wordEnding, $allVowels )
  433. || in_array( $wordEnding, $Sonants )
  434. || in_array( $wordEnding, $Sibilants )
  435. ) {
  436. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  437. $word = $word . "den";
  438. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  439. $word = $word . "dan";
  440. }
  441. } elseif ( in_array( $wordEnding, $Nasals ) ) {
  442. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  443. $word = $word . "nen";
  444. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  445. $word = $word . "nan";
  446. }
  447. }
  448. break;
  449. case "dc51":
  450. case "possessive ablative": # täweldık + şığıs
  451. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
  452. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  453. $word = $word . "nen";
  454. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  455. $word = $word . "nan";
  456. }
  457. } elseif ( in_array( $wordEnding, $secondPerson ) ) {
  458. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  459. $word = $word . "den";
  460. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  461. $word = $word . "dan";
  462. }
  463. }
  464. break;
  465. case "dc6":
  466. case "comitative": # kömektes
  467. if ( in_array( $wordEnding, $Consonants ) ) {
  468. $word = $word . "pen";
  469. } elseif ( in_array( $wordEnding, $allVowels )
  470. || in_array( $wordEnding, $Nasals )
  471. || in_array( $wordEnding, $Sonants )
  472. ) {
  473. $word = $word . "men";
  474. } elseif ( in_array( $wordEnding, $Sibilants ) ) {
  475. $word = $word . "ben";
  476. }
  477. break;
  478. case "dc61":
  479. case "possessive comitative": # täweldık + kömektes
  480. if ( in_array( $wordEnding, $Consonants ) ) {
  481. $word = $word . "penen";
  482. } elseif ( in_array( $wordEnding, $allVowels )
  483. || in_array( $wordEnding, $Nasals )
  484. || in_array( $wordEnding, $Sonants )
  485. ) {
  486. $word = $word . "menen";
  487. } elseif ( in_array( $wordEnding, $Sibilants ) ) {
  488. $word = $word . "benen";
  489. }
  490. break;
  491. default: # dc0 #nominative #ataw
  492. }
  493. return $word;
  494. }
  495. /**
  496. * @param string $word
  497. * @param string $case
  498. * @return string
  499. */
  500. function convertGrammarKk_arab( $word, $case ) {
  501. global $wgGrammarForms;
  502. if ( isset( $wgGrammarForms['kk-cn'][$case][$word] ) ) {
  503. return $wgGrammarForms['kk-cn'][$case][$word];
  504. }
  505. if ( isset( $wgGrammarForms['kk-arab'][$case][$word] ) ) {
  506. return $wgGrammarForms['kk-arab'][$case][$word];
  507. }
  508. // Set up some constants...
  509. // Vowels in last syllable
  510. $frontVowels = [ "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە" ];
  511. $backVowels = [ "ا", "و", "ۇ", "ى" ];
  512. $allVowels = [ "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" ];
  513. // Preceding letters
  514. $Nasals = [ "م", "ن", "ڭ" ];
  515. $Sonants = [ "ي", "ي", "ل", "ر", "ۋ" ];
  516. $Consonants = [ "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" ];
  517. $Sibilants = [ "ج", "ز" ];
  518. $Sonorants = [ "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز" ];
  519. // Possessives
  520. $firstPerson = [ "م", "ڭ" ]; // 1st singular, 2nd unformal
  521. $secondPerson = [ "ز" ]; // 1st plural, 2nd formal
  522. $thirdPerson = [ "ى", "ٸ" ]; // 3rd
  523. $lastLetter = $this->lastLetter( $word, $allVowels );
  524. $wordEnding = $lastLetter[0];
  525. $wordLastVowel = $lastLetter[1];
  526. // Now convert the word
  527. switch ( $case ) {
  528. case "dc1":
  529. case "genitive": # ilik
  530. if ( in_array( $wordEnding, $Consonants ) ) {
  531. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  532. $word = $word . "تٸڭ";
  533. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  534. $word = $word . "تىڭ";
  535. }
  536. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
  537. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  538. $word = $word . "نٸڭ";
  539. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  540. $word = $word . "نىڭ";
  541. }
  542. } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
  543. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  544. $word = $word . "دٸڭ";
  545. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  546. $word = $word . "دىڭ";
  547. }
  548. }
  549. break;
  550. case "dc2":
  551. case "dative": # barıs
  552. if ( in_array( $wordEnding, $Consonants ) ) {
  553. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  554. $word = $word . "كە";
  555. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  556. $word = $word . "قا";
  557. }
  558. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
  559. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  560. $word = $word . "گە";
  561. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  562. $word = $word . "عا";
  563. }
  564. }
  565. break;
  566. case "dc21":
  567. case "possessive dative": # täweldık + barıs
  568. if ( in_array( $wordEnding, $firstPerson ) ) {
  569. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  570. $word = $word . "ە";
  571. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  572. $word = $word . "ا";
  573. }
  574. } elseif ( in_array( $wordEnding, $secondPerson ) ) {
  575. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  576. $word = $word . "گە";
  577. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  578. $word = $word . "عا";
  579. }
  580. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  581. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  582. $word = $word . "نە";
  583. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  584. $word = $word . "نا";
  585. }
  586. }
  587. break;
  588. case "dc3":
  589. case "accusative": # tabıs
  590. if ( in_array( $wordEnding, $Consonants ) ) {
  591. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  592. $word = $word . "تٸ";
  593. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  594. $word = $word . "تى";
  595. }
  596. } elseif ( in_array( $wordEnding, $allVowels ) ) {
  597. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  598. $word = $word . "نٸ";
  599. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  600. $word = $word . "نى";
  601. }
  602. } elseif ( in_array( $wordEnding, $Sonorants ) ) {
  603. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  604. $word = $word . "دٸ";
  605. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  606. $word = $word . "دى";
  607. }
  608. }
  609. break;
  610. case "dc31":
  611. case "possessive accusative": # täweldık + tabıs
  612. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
  613. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  614. $word = $word . "دٸ";
  615. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  616. $word = $word . "دى";
  617. }
  618. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  619. $word = $word . "ن";
  620. }
  621. break;
  622. case "dc4":
  623. case "locative": # jatıs
  624. if ( in_array( $wordEnding, $Consonants ) ) {
  625. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  626. $word = $word . "تە";
  627. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  628. $word = $word . "تا";
  629. }
  630. } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
  631. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  632. $word = $word . "دە";
  633. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  634. $word = $word . "دا";
  635. }
  636. }
  637. break;
  638. case "dc41":
  639. case "possessive locative": # täweldık + jatıs
  640. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
  641. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  642. $word = $word . "دە";
  643. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  644. $word = $word . "دا";
  645. }
  646. } elseif ( in_array( $wordEnding, $thirdPerson ) ) {
  647. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  648. $word = $word . "ندە";
  649. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  650. $word = $word . "ندا";
  651. }
  652. }
  653. break;
  654. case "dc5":
  655. case "ablative": # şığıs
  656. if ( in_array( $wordEnding, $Consonants ) ) {
  657. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  658. $word = $word . "تەن";
  659. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  660. $word = $word . "تان";
  661. }
  662. } elseif ( in_array( $wordEnding, $allVowels )
  663. || in_array( $wordEnding, $Sonants )
  664. || in_array( $wordEnding, $Sibilants )
  665. ) {
  666. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  667. $word = $word . "دەن";
  668. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  669. $word = $word . "دان";
  670. }
  671. } elseif ( in_array( $wordEnding, $Nasals ) ) {
  672. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  673. $word = $word . "نەن";
  674. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  675. $word = $word . "نان";
  676. }
  677. }
  678. break;
  679. case "dc51":
  680. case "possessive ablative": # täweldık + şığıs
  681. if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
  682. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  683. $word = $word . "نەن";
  684. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  685. $word = $word . "نان";
  686. }
  687. } elseif ( in_array( $wordEnding, $secondPerson ) ) {
  688. if ( in_array( $wordLastVowel, $frontVowels ) ) {
  689. $word = $word . "دەن";
  690. } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
  691. $word = $word . "دان";
  692. }
  693. }
  694. break;
  695. case "dc6":
  696. case "comitative": # kömektes
  697. if ( in_array( $wordEnding, $Consonants ) ) {
  698. $word = $word . "پەن";
  699. } elseif ( in_array( $wordEnding, $allVowels )
  700. || in_array( $wordEnding, $Nasals )
  701. || in_array( $wordEnding, $Sonants )
  702. ) {
  703. $word = $word . "مەن";
  704. } elseif ( in_array( $wordEnding, $Sibilants ) ) {
  705. $word = $word . "بەن";
  706. }
  707. break;
  708. case "dc61":
  709. case "possessive comitative": # täweldık + kömektes
  710. if ( in_array( $wordEnding, $Consonants ) ) {
  711. $word = $word . "پەنەن";
  712. } elseif ( in_array( $wordEnding, $allVowels )
  713. || in_array( $wordEnding, $Nasals )
  714. || in_array( $wordEnding, $Sonants )
  715. ) {
  716. $word = $word . "مەنەن";
  717. } elseif ( in_array( $wordEnding, $Sibilants ) ) {
  718. $word = $word . "بەنەن";
  719. }
  720. break;
  721. default: # dc0 #nominative #ataw
  722. }
  723. return $word;
  724. }
  725. /**
  726. * @param string $word
  727. * @param array $allVowels
  728. * @return array
  729. */
  730. function lastLetter( $word, $allVowels ) {
  731. $lastLetter = [];
  732. // Put the word in a form we can play with since we're using UTF-8
  733. $ar = preg_split( '//u', parent::lc( $word ), -1, PREG_SPLIT_NO_EMPTY );
  734. // Here's an array with the order of the letters in the word reversed
  735. // so we can find a match quicker *shrug*
  736. $wordReversed = array_reverse( $ar );
  737. // Here's the last letter in the word
  738. $lastLetter[0] = $ar[count( $ar ) - 1];
  739. // Find the last vowel in the word
  740. $lastLetter[1] = null;
  741. foreach ( $wordReversed as $xvalue ) {
  742. foreach ( $allVowels as $yvalue ) {
  743. if ( strcmp( $xvalue, $yvalue ) == 0 ) {
  744. $lastLetter[1] = $xvalue;
  745. break;
  746. } else {
  747. continue;
  748. }
  749. }
  750. if ( $lastLetter[1] !== null ) {
  751. break;
  752. } else {
  753. continue;
  754. }
  755. }
  756. return $lastLetter;
  757. }
  758. }