MediaWiki REL1_40
LanguageTyv.php
Go to the documentation of this file.
1<?php
23
31class LanguageTyv extends Language {
40 public function convertGrammar( $word, $case ) {
41 $grammarForms =
42 MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
43 if ( isset( $grammarForms['tyv'][$case][$word] ) ) {
44 return $grammarForms['tyv'][$case][$word];
45 }
46
47 // Set up some constants...
48 $allVowels = [ "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я" ];
49 $frontVowels = [ "е", "и", "э", "ө", "ү" ];
50 $backVowels = [ "а", "ё", "о", "у", "ы", "ю", "я" ];
51 $unroundFrontVowels = [ "е", "и", "э" ];
52 $roundFrontVowels = [ "ө", "ү" ];
53 $unroundBackVowels = [ "а", "ы", "я" ];
54 $roundBackVowels = [ "ё", "о", "у", "ю" ];
55 $unvoicedPhonemes = [ "т", "п", "с", "ш", "к", "ч", "х" ];
56 $directiveUnvoicedStems = [ "т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң" ];
57 $directiveVoicedStems = [ "д", "б", "з", "ж", "г", "р", "й" ];
58
59 // Put the word in a form we can play with since we're using UTF-8
60 preg_match_all( '/./us', $word, $ar );
61
62 // Here's the last letter in the word
63 $wordEnding = $ar[0][count( $ar[0] ) - 1];
64
65 // Here's an array with the order of the letters in the word reversed so
66 // we can find a match quicker. *shrug*
67 $wordReversed = array_reverse( $ar[0] );
68
69 // Find the last vowel in the word
70 $wordLastVowel = null;
71 foreach ( $wordReversed as $xvalue ) {
72 foreach ( $allVowels as $yvalue ) {
73 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
74 $wordLastVowel = $xvalue;
75 break;
76 }
77 }
78
79 if ( $wordLastVowel !== null ) {
80 break;
81 }
82 }
83
84 // Now convert the word
85 switch ( $case ) {
86 case "genitive":
87 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
88 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
89 $word = implode( "", $ar[0] ) . "түң";
90 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
91 $word = implode( "", $ar[0] ) . "тиң";
92 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
93 $word = implode( "", $ar[0] ) . "туң";
94 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
95 $word = implode( "", $ar[0] ) . "тың";
96 } else {
97 }
98 } elseif ( $wordEnding === "л" ) {
99 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
100 $word = implode( "", $ar[0] ) . "дүң";
101 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
102 $word = implode( "", $ar[0] ) . "диң";
103 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
104 $word = implode( "", $ar[0] ) . "дуң";
105 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
106 $word = implode( "", $ar[0] ) . "дың";
107 } else {
108 }
109 } else {
110 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
111 $word = implode( "", $ar[0] ) . "нүң";
112 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
113 $word = implode( "", $ar[0] ) . "ниң";
114 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
115 $word = implode( "", $ar[0] ) . "нуң";
116 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
117 $word = implode( "", $ar[0] ) . "ның";
118 } else {
119 }
120 }
121 break;
122 case "dative":
123 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
124 if ( in_array( $wordLastVowel, $frontVowels ) ) {
125 $word = implode( "", $ar[0] ) . "ке";
126 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
127 $word = implode( "", $ar[0] ) . "ка";
128 } else {
129 }
130 } else {
131 if ( in_array( $wordLastVowel, $frontVowels ) ) {
132 $word = implode( "", $ar[0] ) . "ге";
133 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
134 $word = implode( "", $ar[0] ) . "га";
135 } else {
136 }
137 }
138 break;
139 case "accusative":
140 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
141 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
142 $word = implode( "", $ar[0] ) . "тү";
143 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
144 $word = implode( "", $ar[0] ) . "ти";
145 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
146 $word = implode( "", $ar[0] ) . "ту";
147 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
148 $word = implode( "", $ar[0] ) . "ты";
149 } else {
150 }
151 } elseif ( $wordEnding === "л" ) {
152 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
153 $word = implode( "", $ar[0] ) . "дү";
154 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
155 $word = implode( "", $ar[0] ) . "ди";
156 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
157 $word = implode( "", $ar[0] ) . "ду";
158 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
159 $word = implode( "", $ar[0] ) . "ды";
160 } else {
161 }
162 } else {
163 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
164 $word = implode( "", $ar[0] ) . "нү";
165 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
166 $word = implode( "", $ar[0] ) . "ни";
167 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
168 $word = implode( "", $ar[0] ) . "ну";
169 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
170 $word = implode( "", $ar[0] ) . "ны";
171 } else {
172 }
173 }
174 break;
175 case "locative":
176 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
177 if ( in_array( $wordLastVowel, $frontVowels ) ) {
178 $word = implode( "", $ar[0] ) . "те";
179 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
180 $word = implode( "", $ar[0] ) . "та";
181 } else {
182 }
183 } else {
184 if ( in_array( $wordLastVowel, $frontVowels ) ) {
185 $word = implode( "", $ar[0] ) . "де";
186 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
187 $word = implode( "", $ar[0] ) . "да";
188 } else {
189 }
190 }
191 break;
192 case "ablative":
193 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
194 if ( in_array( $wordLastVowel, $frontVowels ) ) {
195 $word = implode( "", $ar[0] ) . "тен";
196 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
197 $word = implode( "", $ar[0] ) . "тан";
198 } else {
199 }
200 } else {
201 if ( in_array( $wordLastVowel, $frontVowels ) ) {
202 $word = implode( "", $ar[0] ) . "ден";
203 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
204 $word = implode( "", $ar[0] ) . "дан";
205 } else {
206 }
207 }
208 break;
209 case "directive1":
210 if ( in_array( $wordEnding, $directiveVoicedStems ) ) {
211 $word = implode( "", $ar[0] ) . "же";
212 } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) {
213 $word = implode( "", $ar[0] ) . "че";
214 } else {
215 }
216 break;
217 case "directive2":
218 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
219 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
220 $word = implode( "", $ar[0] ) . "түве";
221 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
222 $word = implode( "", $ar[0] ) . "тиве";
223 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
224 $word = implode( "", $ar[0] ) . "туве";
225 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
226 $word = implode( "", $ar[0] ) . "тыве";
227 } else {
228 }
229 } else {
230 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
231 $word = implode( "", $ar[0] ) . "дүве";
232 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
233 $word = implode( "", $ar[0] ) . "диве";
234 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
235 $word = implode( "", $ar[0] ) . "дуве";
236 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
237 $word = implode( "", $ar[0] ) . "дыве";
238 } else {
239 }
240 }
241 break;
242 default:
243 break;
244 }
245
246 return $word;
247 }
248}
Tyvan localization (Тыва дыл)
convertGrammar( $word, $case)
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} ...
Base class for language-specific code.
Definition Language.php:56
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.