LanguageKk_cyrl.php 25 KB

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