MediaWiki  REL1_19
LanguageKk_cyrl.php
Go to the documentation of this file.
00001 <?php
00007 class LanguageKk_cyrl extends Language {
00008 
00009         # Convert from the nominative form of a noun to some other case
00010         # Invoked with {{GRAMMAR:case|word}}
00011 
00019         function convertGrammarKk_cyrl( $word, $case ) {
00020                 global $wgGrammarForms;
00021                 if ( isset( $wgGrammarForms['kk-kz'][$case][$word] ) ) {
00022                         return $wgGrammarForms['kk-kz'][$case][$word];
00023                 }
00024                 if ( isset( $wgGrammarForms['kk-cyrl'][$case][$word] ) ) {
00025                         return $wgGrammarForms['kk-cyrl'][$case][$word];
00026                 }
00027                 // Set up some constants...
00028                 // Vowels in last syllable
00029                 $frontVowels = array( "е", "ө", "ү", "і", "ә", "э", "я", "ё", "и" );
00030                 $backVowels = array( "а", "о", "ұ", "ы" );
00031                 $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё", "и" );
00032                 // Preceding letters
00033                 $Nasals = array( "м", "н", "ң" );
00034                 $Sonants = array( "и", "й", "л", "р", "у", "ю" );
00035                 $Consonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
00036                 $Sibilants = array( "ж", "з" );
00037                 $Sonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з" );
00038 
00039                 // Possessives
00040                 $firstPerson = array( "м", "ң" ); // 1st singular, 2nd unformal
00041                 $secondPerson = array( "з" ); // 1st plural, 2nd formal
00042                 $thirdPerson = array( "ы", "і" ); // 3rd
00043 
00044                 $lastLetter = $this->lastLetter( $word, $allVowels );
00045                 $wordEnding =& $lastLetter[0];
00046                 $wordLastVowel =& $lastLetter[1];
00047 
00048                 // Now convert the word
00049                 switch ( $case ) {
00050                         case "dc1":
00051                         case "genitive": # ilik
00052                                 if ( in_array( $wordEnding, $Consonants ) ) {
00053                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00054                                                 $word = $word . "тің";
00055                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00056                                                 $word = $word . "тың";
00057                                         }
00058                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
00059                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00060                                                 $word = $word . "нің";
00061                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00062                                                 $word = $word . "ның";
00063                                         }
00064                                 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
00065                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00066                                                 $word = $word . "дің";
00067                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00068                                                 $word = $word . "дың";
00069                                         }
00070                                 }
00071                                 break;
00072                         case "dc2":
00073                         case "dative": # barıs
00074                                 if ( in_array( $wordEnding, $Consonants ) ) {
00075                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00076                                                 $word = $word . "ке";
00077                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00078                                                 $word = $word . "қа";
00079                                         }
00080                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
00081                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00082                                                 $word = $word . "ге";
00083                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00084                                                 $word = $word . "ға";
00085                                         }
00086                                 }
00087                                 break;
00088                         case "dc21":
00089                         case "possessive dative": # täweldık + barıs
00090                                 if ( in_array( $wordEnding, $firstPerson ) ) {
00091                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00092                                                 $word = $word . "е";
00093                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00094                                                 $word = $word . "а";
00095                                         }
00096                                 } elseif ( in_array( $wordEnding, $secondPerson  ) ) {
00097                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00098                                                 $word = $word . "ге";
00099                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00100                                                 $word = $word . "ға";
00101                                         }
00102                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00103                                   if ( in_array( $wordLastVowel, $frontVowels ) ) {
00104                                                 $word = $word . "не";
00105                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00106                                                 $word = $word . "на";
00107                                         }
00108                                 }
00109                                 break;
00110                         case "dc3":
00111                         case "accusative": # tabıs
00112                                 if ( in_array( $wordEnding, $Consonants ) ) {
00113                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00114                                                 $word = $word . "ті";
00115                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00116                                                 $word = $word . "ты";
00117                                         }
00118                                 } elseif ( in_array( $wordEnding, $allVowels ) ) {
00119                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00120                                                 $word = $word . "ні";
00121                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00122                                                 $word = $word . "ны";
00123                                         }
00124                                 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
00125                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00126                                                 $word = $word . "ді";
00127                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00128                                                 $word = $word . "ды";
00129                                         }
00130                                 }
00131                                 break;
00132                         case "dc31":
00133                         case "possessive accusative": # täweldık + tabıs
00134                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson  ) ) {
00135                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00136                                                 $word = $word . "ді";
00137                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00138                                                 $word = $word . "ды";
00139                                         }
00140                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00141                                                 $word = $word . "н";
00142                                 }
00143                                 break;
00144                         case "dc4":
00145                         case "locative": # jatıs
00146                                 if ( in_array( $wordEnding, $Consonants ) ) {
00147                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00148                                                 $word = $word . "те";
00149                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00150                                                 $word = $word . "та";
00151                                         }
00152                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
00153                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00154                                                 $word = $word . "де";
00155                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00156                                                 $word = $word . "да";
00157                                         }
00158                                 }
00159                                 break;
00160                         case "dc41":
00161                         case "possessive locative": # täweldık + jatıs
00162                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson  ) ) {
00163                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00164                                                 $word = $word . "де";
00165                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00166                                                 $word = $word . "да";
00167                                         }
00168                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00169                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00170                                                 $word = $word . "нде";
00171                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00172                                                 $word = $word . "нда";
00173                                         }
00174                                 }
00175                                 break;
00176                         case "dc5":
00177                         case "ablative": # şığıs
00178                                 if ( in_array( $wordEnding, $Consonants ) ) {
00179                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00180                                                 $word = $word . "тен";
00181                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00182                                                 $word = $word . "тан";
00183                                         }
00184                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
00185                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00186                                                 $word = $word . "ден";
00187                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00188                                                 $word = $word . "дан";
00189                                         }
00190                                 }  elseif ( in_array( $wordEnding, $Nasals ) ) {
00191                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00192                                                 $word = $word . "нен";
00193                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00194                                                 $word = $word . "нан";
00195                                         }
00196                                 }
00197                                 break;
00198                         case "dc51":
00199                         case "possessive ablative": # täweldık + şığıs
00200                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson  ) ) {
00201                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00202                                                 $word = $word . "нен";
00203                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00204                                                 $word = $word . "нан";
00205                                         }
00206                                 } elseif ( in_array( $wordEnding, $secondPerson  ) ) {
00207                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00208                                                 $word = $word . "ден";
00209                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00210                                                 $word = $word . "дан";
00211                                         }
00212                                 }
00213                                 break;
00214                         case "dc6":
00215                         case "comitative": # kömektes
00216                                 if ( in_array( $wordEnding, $Consonants ) ) {
00217                                                 $word = $word . "пен";
00218                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
00219                                                 $word = $word . "мен";
00220                                 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
00221                                                 $word = $word . "бен";
00222                                 }
00223                                 break;
00224                         case "dc61":
00225                         case "possessive comitative": # täweldık + kömektes
00226                                 if ( in_array( $wordEnding, $Consonants ) ) {
00227                                                 $word = $word . "пенен";
00228                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
00229                                                 $word = $word . "менен";
00230                                 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
00231                                                 $word = $word . "бенен";
00232                                 }
00233                                 break;
00234                         default: # dc0 #nominative #ataw
00235                 }
00236                 return $word;
00237         }
00238 
00244         function convertGrammarKk_latn( $word, $case ) {
00245                 global $wgGrammarForms;
00246                 if ( isset( $wgGrammarForms['kk-tr'][$case][$word] ) ) {
00247                         return $wgGrammarForms['kk-tr'][$case][$word];
00248                 }
00249                 if ( isset( $wgGrammarForms['kk-latn'][$case][$word] ) ) {
00250                         return $wgGrammarForms['kk-latn'][$case][$word];
00251                 }
00252                 // Set up some constants...
00253                 // Vowels in last syllable
00254                 $frontVowels = array( "e", "ö", "ü", "i", "ä", "é" );
00255                 $backVowels = array( "a", "o", "u", "ı" );
00256                 $allVowels = array( "e", "ö", "ü", "i", "ä", "é", "a", "o", "u", "ı" );
00257                 // Preceding letters
00258                 $Nasals = array( "m", "n", "ñ" );
00259                 $Sonants = array( "ï", "y", "ý", "l", "r", "w" );
00260                 $Consonants = array( "p", "f", "k", "q", "t", "ş", "s", "x", "c", "ç", "b", "v", "g", "d" );
00261                 $Sibilants = array( "j", "z" );
00262                 $Sonorants = array( "ï", "y", "ý", "l", "r", "w", "m", "n", "ñ", "j", "z" );
00263 
00264                 // Possessives
00265                 $firstPerson = array( "m", "ñ" ); // 1st singular, 2nd unformal
00266                 $secondPerson = array( "z" ); // 1st plural, 2nd formal
00267                 $thirdPerson = array( "ı", "i" ); // 3rd
00268 
00269                 $lastLetter = $this->lastLetter( $word, $allVowels );
00270                 $wordEnding =& $lastLetter[0];
00271                 $wordLastVowel =& $lastLetter[1];
00272 
00273                 // Now convert the word
00274                 switch ( $case ) {
00275                         case "dc1":
00276                         case "genitive": # ilik
00277                                 if ( in_array( $wordEnding, $Consonants ) ) {
00278                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00279                                                 $word = $word . "tiñ";
00280                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00281                                                 $word = $word . "tıñ";
00282                                         }
00283                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
00284                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00285                                                 $word = $word . "niñ";
00286                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00287                                                 $word = $word . "nıñ";
00288                                         }
00289                                 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
00290                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00291                                                 $word = $word . "diñ";
00292                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00293                                                 $word = $word . "dıñ";
00294                                         }
00295                                 }
00296                                 break;
00297                         case "dc2":
00298                         case "dative": # barıs
00299                                 if ( in_array( $wordEnding, $Consonants ) ) {
00300                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00301                                                 $word = $word . "ke";
00302                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00303                                                 $word = $word . "qa";
00304                                         }
00305                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
00306                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00307                                                 $word = $word . "ge";
00308                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00309                                                 $word = $word . "ğa";
00310                                         }
00311                                 }
00312                                 break;
00313                         case "dc21":
00314                         case "possessive dative": # täweldık + barıs
00315                                 if ( in_array( $wordEnding, $firstPerson ) ) {
00316                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00317                                                 $word = $word . "e";
00318                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00319                                                 $word = $word . "a";
00320                                         }
00321                                 } elseif ( in_array( $wordEnding, $secondPerson  ) ) {
00322                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00323                                                 $word = $word . "ge";
00324                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00325                                                 $word = $word . "ğa";
00326                                         }
00327                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00328                                   if ( in_array( $wordLastVowel, $frontVowels ) ) {
00329                                                 $word = $word . "ne";
00330                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00331                                                 $word = $word . "na";
00332                                         }
00333                                 }
00334                                 break;
00335                         case "dc3":
00336                         case "accusative": # tabıs
00337                                 if ( in_array( $wordEnding, $Consonants ) ) {
00338                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00339                                                 $word = $word . "ti";
00340                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00341                                                 $word = $word . "tı";
00342                                         }
00343                                 } elseif ( in_array( $wordEnding, $allVowels ) ) {
00344                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00345                                                 $word = $word . "ni";
00346                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00347                                                 $word = $word . "nı";
00348                                         }
00349                                 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
00350                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00351                                                 $word = $word . "di";
00352                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00353                                                 $word = $word . "dı";
00354                                         }
00355                                 }
00356                                 break;
00357                         case "dc31":
00358                         case "possessive accusative": # täweldık + tabıs
00359                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson  ) ) {
00360                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00361                                                 $word = $word . "di";
00362                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00363                                                 $word = $word . "dı";
00364                                         }
00365                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00366                                                 $word = $word . "n";
00367                                 }
00368                                 break;
00369                         case "dc4":
00370                         case "locative": # jatıs
00371                                 if ( in_array( $wordEnding, $Consonants ) ) {
00372                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00373                                                 $word = $word . "te";
00374                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00375                                                 $word = $word . "ta";
00376                                         }
00377                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
00378                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00379                                                 $word = $word . "de";
00380                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00381                                                 $word = $word . "da";
00382                                         }
00383                                 }
00384                                 break;
00385                         case "dc41":
00386                         case "possessive locative": # täweldık + jatıs
00387                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson  ) ) {
00388                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00389                                                 $word = $word . "de";
00390                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00391                                                 $word = $word . "da";
00392                                         }
00393                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00394                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00395                                                 $word = $word . "nde";
00396                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00397                                                 $word = $word . "nda";
00398                                         }
00399                                 }
00400                                 break;
00401                         case "dc5":
00402                         case "ablative": # şığıs
00403                                 if ( in_array( $wordEnding, $Consonants ) ) {
00404                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00405                                                 $word = $word . "ten";
00406                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00407                                                 $word = $word . "tan";
00408                                         }
00409                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
00410                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00411                                                 $word = $word . "den";
00412                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00413                                                 $word = $word . "dan";
00414                                         }
00415                                 }  elseif ( in_array( $wordEnding, $Nasals ) ) {
00416                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00417                                                 $word = $word . "nen";
00418                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00419                                                 $word = $word . "nan";
00420                                         }
00421                                 }
00422                                 break;
00423                         case "dc51":
00424                         case "possessive ablative": # täweldık + şığıs
00425                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson  ) ) {
00426                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00427                                                 $word = $word . "nen";
00428                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00429                                                 $word = $word . "nan";
00430                                         }
00431                                 } elseif ( in_array( $wordEnding, $secondPerson  ) ) {
00432                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00433                                                 $word = $word . "den";
00434                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00435                                                 $word = $word . "dan";
00436                                         }
00437                                 }
00438                                 break;
00439                         case "dc6":
00440                         case "comitative": # kömektes
00441                                 if ( in_array( $wordEnding, $Consonants ) ) {
00442                                                 $word = $word . "pen";
00443                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
00444                                                 $word = $word . "men";
00445                                 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
00446                                                 $word = $word . "ben";
00447                                 }
00448                                 break;
00449                         case "dc61":
00450                         case "possessive comitative": # täweldık + kömektes
00451                                 if ( in_array( $wordEnding, $Consonants ) ) {
00452                                                 $word = $word . "penen";
00453                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
00454                                                 $word = $word . "menen";
00455                                 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
00456                                                 $word = $word . "benen";
00457                                 }
00458                                 break;
00459                         default: # dc0 #nominative #ataw
00460                 }
00461                 return $word;
00462         }
00463 
00469         function convertGrammarKk_arab( $word, $case ) {
00470                 global $wgGrammarForms;
00471                 if ( isset( $wgGrammarForms['kk-cn'][$case][$word] ) ) {
00472                         return $wgGrammarForms['kk-cn'][$case][$word];
00473                 }
00474                 if ( isset( $wgGrammarForms['kk-arab'][$case][$word] ) ) {
00475                         return $wgGrammarForms['kk-arab'][$case][$word];
00476                 }
00477                 // Set up some constants...
00478                 // Vowels in last syllable
00479                 $frontVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە" );
00480                 $backVowels = array( "ا", "و", "ۇ", "ى"  );
00481                 $allVowels = array( "ە", "ٶ", "ٷ", "ٸ", "ٵ", "ە", "ا", "و", "ۇ", "ى" );
00482                 // Preceding letters
00483                 $Nasals = array( "م", "ن", "ڭ" );
00484                 $Sonants = array( "ي", "ي", "ل", "ر", "ۋ" );
00485                 $Consonants = array( "پ", "ف", "ك", "ق", "ت", "ش", "س", "ح", "تس", "چ", "ب", "ۆ", "گ", "د" );
00486                 $Sibilants = array( "ج", "ز" );
00487                 $Sonorants = array( "ي", "ي", "ل", "ر", "ۋ", "م", "ن", "ڭ", "ج", "ز" );
00488 
00489                 // Possessives
00490                 $firstPerson = array( "م", "ڭ" ); // 1st singular, 2nd unformal
00491                 $secondPerson = array( "ز" ); // 1st plural, 2nd formal
00492                 $thirdPerson = array( "ى", "ٸ" ); // 3rd
00493 
00494                 $lastLetter = $this->lastLetter( $word, $allVowels );
00495                 $wordEnding = $lastLetter[0];
00496                 $wordLastVowel = $lastLetter[1];
00497 
00498                 // Now convert the word
00499                 switch ( $case ) {
00500                         case "dc1":
00501                         case "genitive": # ilik
00502                                 if ( in_array( $wordEnding, $Consonants ) ) {
00503                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00504                                                 $word = $word . "تٸڭ";
00505                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00506                                                 $word = $word . "تىڭ";
00507                                         }
00508                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) ) {
00509                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00510                                                 $word = $word . "نٸڭ";
00511                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00512                                                 $word = $word . "نىڭ";
00513                                         }
00514                                 } elseif ( in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
00515                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00516                                                 $word = $word . "دٸڭ";
00517                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00518                                                 $word = $word . "دىڭ";
00519                                         }
00520                                 }
00521                                 break;
00522                         case "dc2":
00523                         case "dative": # barıs
00524                                 if ( in_array( $wordEnding, $Consonants ) ) {
00525                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00526                                                 $word = $word . "كە";
00527                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00528                                                 $word = $word . "قا";
00529                                         }
00530                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
00531                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00532                                                 $word = $word . "گە";
00533                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00534                                                 $word = $word . "عا";
00535                                         }
00536                                 }
00537                                 break;
00538                         case "dc21":
00539                         case "possessive dative": # täweldık + barıs
00540                                 if ( in_array( $wordEnding, $firstPerson ) ) {
00541                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00542                                                 $word = $word . "ە";
00543                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00544                                                 $word = $word . "ا";
00545                                         }
00546                                 } elseif ( in_array( $wordEnding, $secondPerson  ) ) {
00547                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00548                                                 $word = $word . "گە";
00549                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00550                                                 $word = $word . "عا";
00551                                         }
00552                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00553                                   if ( in_array( $wordLastVowel, $frontVowels ) ) {
00554                                                 $word = $word . "نە";
00555                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00556                                                 $word = $word . "نا";
00557                                         }
00558                                 }
00559                                 break;
00560                         case "dc3":
00561                         case "accusative": # tabıs
00562                                 if ( in_array( $wordEnding, $Consonants ) ) {
00563                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00564                                                 $word = $word . "تٸ";
00565                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00566                                                 $word = $word . "تى";
00567                                         }
00568                                 } elseif ( in_array( $wordEnding, $allVowels ) ) {
00569                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00570                                                 $word = $word . "نٸ";
00571                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00572                                                 $word = $word . "نى";
00573                                         }
00574                                 } elseif ( in_array( $wordEnding, $Sonorants ) ) {
00575                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00576                                                 $word = $word . "دٸ";
00577                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00578                                                 $word = $word . "دى";
00579                                         }
00580                                 }
00581                                 break;
00582                         case "dc31":
00583                         case "possessive accusative": # täweldık + tabıs
00584                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson  ) ) {
00585                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00586                                                 $word = $word . "دٸ";
00587                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00588                                                 $word = $word . "دى";
00589                                         }
00590                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00591                                                 $word = $word . "ن";
00592                                 }
00593                                 break;
00594                         case "dc4":
00595                         case "locative": # jatıs
00596                                 if ( in_array( $wordEnding, $Consonants ) ) {
00597                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00598                                                 $word = $word . "تە";
00599                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00600                                                 $word = $word . "تا";
00601                                         }
00602                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonorants ) ) {
00603                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00604                                                 $word = $word . "دە";
00605                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00606                                                 $word = $word . "دا";
00607                                         }
00608                                 }
00609                                 break;
00610                         case "dc41":
00611                         case "possessive locative": # täweldık + jatıs
00612                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson  ) ) {
00613                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00614                                                 $word = $word . "دە";
00615                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00616                                                 $word = $word . "دا";
00617                                         }
00618                                 } elseif ( in_array( $wordEnding, $thirdPerson  ) ) {
00619                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00620                                                 $word = $word . "ندە";
00621                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00622                                                 $word = $word . "ندا";
00623                                         }
00624                                 }
00625                                 break;
00626                         case "dc5":
00627                         case "ablative": # şığıs
00628                                 if ( in_array( $wordEnding, $Consonants ) ) {
00629                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00630                                                 $word = $word . "تەن";
00631                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00632                                                 $word = $word . "تان";
00633                                         }
00634                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Sonants ) || in_array( $wordEnding, $Sibilants ) ) {
00635                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00636                                                 $word = $word . "دەن";
00637                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00638                                                 $word = $word . "دان";
00639                                         }
00640                                 }  elseif ( in_array( $wordEnding, $Nasals ) ) {
00641                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00642                                                 $word = $word . "نەن";
00643                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00644                                                 $word = $word . "نان";
00645                                         }
00646                                 }
00647                                 break;
00648                         case "dc51":
00649                         case "possessive ablative": # täweldık + şığıs
00650                                 if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $thirdPerson  ) ) {
00651                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00652                                                 $word = $word . "نەن";
00653                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00654                                                 $word = $word . "نان";
00655                                         }
00656                                 } elseif ( in_array( $wordEnding, $secondPerson  ) ) {
00657                                         if ( in_array( $wordLastVowel, $frontVowels ) ) {
00658                                                 $word = $word . "دەن";
00659                                         } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00660                                                 $word = $word . "دان";
00661                                         }
00662                                 }
00663                                 break;
00664                         case "dc6":
00665                         case "comitative": # kömektes
00666                                 if ( in_array( $wordEnding, $Consonants ) ) {
00667                                                 $word = $word . "پەن";
00668                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
00669                                                 $word = $word . "مەن";
00670                                 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
00671                                                 $word = $word . "بەن";
00672                                 }
00673                                 break;
00674                         case "dc61":
00675                         case "possessive comitative": # täweldık + kömektes
00676                                 if ( in_array( $wordEnding, $Consonants ) ) {
00677                                                 $word = $word . "پەنەن";
00678                                 } elseif ( in_array( $wordEnding, $allVowels ) || in_array( $wordEnding, $Nasals ) || in_array( $wordEnding, $Sonants ) ) {
00679                                                 $word = $word . "مەنەن";
00680                                 } elseif ( in_array( $wordEnding, $Sibilants ) ) {
00681                                                 $word = $word . "بەنەن";
00682                                 }
00683                                 break;
00684                         default: # dc0 #nominative #ataw
00685                 }
00686                 return $word;
00687         }
00688 
00694         function lastLetter( $word, $allVowels ) {
00695                 $lastLetter = array();
00696 
00697                 // Put the word in a form we can play with since we're using UTF-8
00698                 $ar = preg_split( '//u', parent::lc( $word ), -1, PREG_SPLIT_NO_EMPTY );
00699 
00700                 // Here's an array with the order of the letters in the word reversed
00701                 // so we can find a match quicker *shrug*
00702                 $wordReversed = array_reverse( $ar );
00703 
00704                 // Here's the last letter in the word
00705                 $lastLetter[0] = $ar[count( $ar ) - 1];
00706 
00707                 // Find the last vowel in the word
00708                 $lastLetter[1] = NULL;
00709                 foreach ( $wordReversed as $xvalue ) {
00710                         foreach ( $allVowels as $yvalue ) {
00711                                 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
00712                                         $lastLetter[1] = $xvalue;
00713                                         break;
00714                                 } else {
00715                                         continue;
00716                                 }
00717                         }
00718                         if ( $lastLetter[1] !== NULL ) {
00719                                 break;
00720                         } else {
00721                                 continue;
00722                         }
00723                 }
00724 
00725                 return $lastLetter;
00726         }
00727 
00735         function commafy( $_ ) {
00736                 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
00737                         return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
00738                 } else {
00739                         return $_;
00740                 }
00741         }
00742 }