MediaWiki
REL1_19
|
00001 <?php 00002 00008 class LanguageTyv extends Language { 00017 function convertGrammar( $word, $case ) { 00018 global $wgGrammarForms; 00019 if ( isset( $wgGrammarForms['tyv'][$case][$word] ) ) { 00020 return $wgGrammarForms['tyv'][$case][$word]; 00021 } 00022 00023 // Set up some constants... 00024 $allVowels = array( "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y" ); 00025 $frontVowels = array( "е", "и", "э", "ө", "ү", "e", "i", "ö", "ü" ); 00026 $backVowels = array( "а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y" ); 00027 $unroundFrontVowels = array( "е", "и", "э", "e", "i" ); 00028 $roundFrontVowels = array( "ө", "ү", "ö", "ü" ); 00029 $unroundBackVowels = array( "а", "ы", "я", "a", "y" ); 00030 $roundBackVowels = array( "ё", "о", "у", "ю", "o", "u" ); 00031 //$voicedPhonemes = array( "д", "б", "з", "ж", "г", "d", "b", "z", "g" ); 00032 $unvoicedPhonemes = array( "т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x" ); 00033 $directiveUnvoicedStems = array( "т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ" ); 00034 $directiveVoicedStems = array( "д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j" ); 00035 00036 //$allSonants = array("л", "м", "н", "ң", "р", "й"); 00037 //$allNasals = array("м", "н", "ң"); 00038 00039 //Put the word in a form we can play with since we're using UTF-8 00040 preg_match_all( '/./us', $word, $ar ); 00041 00042 $wordEnding = $ar[0][count( $ar[0] ) - 1]; // Here's the last letter in the word 00043 $wordReversed = array_reverse( $ar[0] ); // Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug* 00044 00045 // Find the last vowel in the word 00046 $wordLastVowel = NULL; 00047 foreach ( $wordReversed as $xvalue ) { 00048 foreach ( $allVowels as $yvalue ) { 00049 if ( strcmp( $xvalue, $yvalue ) == 0 ) { 00050 $wordLastVowel = $xvalue; 00051 break; 00052 } else { 00053 continue; 00054 } 00055 } 00056 if ( $wordLastVowel !== NULL ) { 00057 break; 00058 } else { 00059 continue; 00060 } 00061 } 00062 00063 // Now convert the word 00064 switch ( $case ) { 00065 case "genitive": 00066 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { 00067 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00068 $word = implode( "", $ar[0] ) . "түң"; 00069 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00070 $word = implode( "", $ar[0] ) . "тиң"; 00071 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00072 $word = implode( "", $ar[0] ) . "туң"; 00073 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00074 $word = implode( "", $ar[0] ) . "тың"; 00075 } else { 00076 } 00077 } elseif ( $wordEnding === "л" || $wordEnding === "l" ) { 00078 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00079 $word = implode( "", $ar[0] ) . "дүң"; 00080 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00081 $word = implode( "", $ar[0] ) . "диң"; 00082 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00083 $word = implode( "", $ar[0] ) . "дуң"; 00084 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00085 $word = implode( "", $ar[0] ) . "дың"; 00086 } else { 00087 } 00088 } else { 00089 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00090 $word = implode( "", $ar[0] ) . "нүң"; 00091 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00092 $word = implode( "", $ar[0] ) . "ниң"; 00093 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00094 $word = implode( "", $ar[0] ) . "нуң"; 00095 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00096 $word = implode( "", $ar[0] ) . "ның"; 00097 } else { 00098 } 00099 } 00100 break; 00101 case "dative": 00102 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { 00103 if ( in_array( $wordLastVowel, $frontVowels ) ) { 00104 $word = implode( "", $ar[0] ) . "ке"; 00105 } elseif ( in_array( $wordLastVowel, $backVowels ) ) { 00106 $word = implode( "", $ar[0] ) . "ка"; 00107 } else { 00108 } 00109 } else { 00110 if ( in_array( $wordLastVowel, $frontVowels ) ) { 00111 $word = implode( "", $ar[0] ) . "ге"; 00112 } elseif ( in_array( $wordLastVowel, $backVowels ) ) { 00113 $word = implode( "", $ar[0] ) . "га"; 00114 } else { 00115 } 00116 } 00117 break; 00118 case "accusative": 00119 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { 00120 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00121 $word = implode( "", $ar[0] ) . "тү"; 00122 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00123 $word = implode( "", $ar[0] ) . "ти"; 00124 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00125 $word = implode( "", $ar[0] ) . "ту"; 00126 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00127 $word = implode( "", $ar[0] ) . "ты"; 00128 } else { 00129 } 00130 } elseif ( $wordEnding === "л" || $wordEnding === "l" ) { 00131 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00132 $word = implode( "", $ar[0] ) . "дү"; 00133 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00134 $word = implode( "", $ar[0] ) . "ди"; 00135 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00136 $word = implode( "", $ar[0] ) . "ду"; 00137 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00138 $word = implode( "", $ar[0] ) . "ды"; 00139 } else { 00140 } 00141 } else { 00142 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00143 $word = implode( "", $ar[0] ) . "нү"; 00144 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00145 $word = implode( "", $ar[0] ) . "ни"; 00146 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00147 $word = implode( "", $ar[0] ) . "ну"; 00148 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00149 $word = implode( "", $ar[0] ) . "ны"; 00150 } else { 00151 } 00152 } 00153 break; 00154 case "locative": 00155 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { 00156 if ( in_array( $wordLastVowel, $frontVowels ) ) { 00157 $word = implode( "", $ar[0] ) . "те"; 00158 } elseif ( in_array( $wordLastVowel, $backVowels ) ) { 00159 $word = implode( "", $ar[0] ) . "та"; 00160 } else { 00161 } 00162 } else { 00163 if ( in_array( $wordLastVowel, $frontVowels ) ) { 00164 $word = implode( "", $ar[0] ) . "де"; 00165 } elseif ( in_array( $wordLastVowel, $backVowels ) ) { 00166 $word = implode( "", $ar[0] ) . "да"; 00167 } else { 00168 } 00169 } 00170 break; 00171 case "ablative": 00172 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { 00173 if ( in_array( $wordLastVowel, $frontVowels ) ) { 00174 $word = implode( "", $ar[0] ) . "тен"; 00175 } elseif ( in_array( $wordLastVowel, $backVowels ) ) { 00176 $word = implode( "", $ar[0] ) . "тан"; 00177 } else { 00178 } 00179 } else { 00180 if ( in_array( $wordLastVowel, $frontVowels ) ) { 00181 $word = implode( "", $ar[0] ) . "ден"; 00182 } elseif ( in_array( $wordLastVowel, $backVowels ) ) { 00183 $word = implode( "", $ar[0] ) . "дан"; 00184 } else { 00185 } 00186 } 00187 break; 00188 case "directive1": 00189 if ( in_array( $wordEnding, $directiveVoicedStems ) ) { 00190 $word = implode( "", $ar[0] ) . "же"; 00191 } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) { 00192 $word = implode( "", $ar[0] ) . "че"; 00193 } else { 00194 } 00195 break; 00196 case "directive2": 00197 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) { 00198 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00199 $word = implode( "", $ar[0] ) . "түве"; 00200 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00201 $word = implode( "", $ar[0] ) . "тиве"; 00202 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00203 $word = implode( "", $ar[0] ) . "туве"; 00204 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00205 $word = implode( "", $ar[0] ) . "тыве"; 00206 } else { 00207 } 00208 } else { 00209 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) { 00210 $word = implode( "", $ar[0] ) . "дүве"; 00211 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) { 00212 $word = implode( "", $ar[0] ) . "диве"; 00213 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) { 00214 $word = implode( "", $ar[0] ) . "дуве"; 00215 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) { 00216 $word = implode( "", $ar[0] ) . "дыве"; 00217 } else { 00218 } 00219 } 00220 break; 00221 default: 00222 break; 00223 } 00224 return $word; 00225 } 00226 }