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