Fix E_NOTICE in r55415 breaking Zh variants
[lhc/web/wiklou.git] / languages / classes / LanguageTyv.php
1 <?php
2
3 /** Tyvan localization (Тыва дыл)
4 * From friends at tyvawiki.org
5 *
6 * @ingroup Language
7 */
8 class LanguageTyv extends Language {
9 /**
10 * Grammatical transformations, needed for inflected languages
11 * Invoked by putting {{grammar:case|word}} in a message
12 *
13 * @param $word string
14 * @param $case string
15 * @return string
16 */
17 function convertGrammar( $word, $case ) {
18 global $wgGrammarForms;
19 if ( isset($wgGrammarForms['tyv'][$case][$word]) ) {
20 return $wgGrammarForms['tyv'][$case][$word];
21 }
22
23 // Set up some constants...
24 $allVowels = array("е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y");
25 $frontVowels = array("е", "и", "э", "ө", "ү", "e", "i", "ö", "ü");
26 $backVowels = array("а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y");
27 $unroundFrontVowels = array("е", "и", "э", "e", "i");
28 $roundFrontVowels = array("ө", "ү", "ö", "ü");
29 $unroundBackVowels = array("а", "ы", "я", "a", "y");
30 $roundBackVowels = array("ё", "о", "у", "ю", "o", "u");
31 $voicedPhonemes = array("д", "б", "з", "ж", "г", "d", "b", "z", "g");
32 $unvoicedPhonemes = array("т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x");
33 $directiveUnvoicedStems = array("т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ");
34 $directiveVoicedStems = array("д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j");
35
36 // $allSonants = array("л", "м", "н", "ң", "р", "й");
37 // $allNasals = array("м", "н", "ң");
38
39 // Put the word in a form we can play with since we're using UTF-8
40 preg_match_all( '/./us', $word, $ar );
41
42 $wordEnding = $ar[0][count($ar[0]) - 1]; //Here's the last letter in the word
43 $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*
44
45 // Find the last vowel in the word
46 $wordLastVowel = NULL;
47 foreach ( $wordReversed as $xvalue ) {
48 foreach ( $allVowels as $yvalue ) {
49 if ( strcmp($xvalue, $yvalue) == 0 ) {
50 $wordLastVowel = $xvalue;
51 break;
52 } else {
53 continue;
54 }
55 }
56 if ( $wordLastVowel !== NULL ) {
57 break;
58 } else {
59 continue;
60 }
61 }
62
63 // Now convert the word
64 switch ( $case ) {
65 case "genitive":
66 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
67 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
68 $word = implode("",$ar[0]) . "түң";
69 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
70 $word = implode("",$ar[0]) . "тиң";
71 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
72 $word = implode("",$ar[0]) . "туң";
73 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
74 $word = implode("",$ar[0]) . "тың";
75 } else {
76 }
77 } elseif ( $wordEnding === "л" || $wordEnding === "l") {
78 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
79 $word = implode("",$ar[0]) . "дүң";
80 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
81 $word = implode("",$ar[0]) . "диң";
82 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
83 $word = implode("",$ar[0]) . "дуң";
84 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
85 $word = implode("",$ar[0]) . "дың";
86 } else {
87 }
88 } else {
89 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
90 $word = implode("",$ar[0]) . "нүң";
91 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
92 $word = implode("",$ar[0]) . "ниң";
93 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
94 $word = implode("",$ar[0]) . "нуң";
95 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
96 $word = implode("",$ar[0]) . "ның";
97 } else {
98 }
99 }
100 break;
101 case "dative":
102 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
103 if ( in_array($wordLastVowel, $frontVowels) ) {
104 $word = implode("",$ar[0]) . "ке";
105 } elseif ( in_array($wordLastVowel, $backVowels) ) {
106 $word = implode("",$ar[0]) . "ка";
107 } else {
108 }
109 } else {
110 if ( in_array($wordLastVowel, $frontVowels) ) {
111 $word = implode("",$ar[0]) . "ге";
112 } elseif ( in_array($wordLastVowel, $backVowels) ) {
113 $word = implode("",$ar[0]) . "га";
114 } else {
115 }
116 }
117 break;
118 case "accusative":
119 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
120 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
121 $word = implode("",$ar[0]) . "тү";
122 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
123 $word = implode("",$ar[0]) . "ти";
124 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
125 $word = implode("",$ar[0]) . "ту";
126 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
127 $word = implode("",$ar[0]) . "ты";
128 } else {
129 }
130 } elseif ( $wordEnding === "л" || $wordEnding === "l") {
131 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
132 $word = implode("",$ar[0]) . "дү";
133 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
134 $word = implode("",$ar[0]) . "ди";
135 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
136 $word = implode("",$ar[0]) . "ду";
137 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
138 $word = implode("",$ar[0]) . "ды";
139 } else {
140 }
141 } else {
142 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
143 $word = implode("",$ar[0]) . "нү";
144 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
145 $word = implode("",$ar[0]) . "ни";
146 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
147 $word = implode("",$ar[0]) . "ну";
148 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
149 $word = implode("",$ar[0]) . "ны";
150 } else {
151 }
152 }
153 break;
154 case "locative":
155 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
156 if ( in_array($wordLastVowel, $frontVowels) ) {
157 $word = implode("",$ar[0]) . "те";
158 } elseif ( in_array($wordLastVowel, $backVowels) ) {
159 $word = implode("",$ar[0]) . "та";
160 } else {
161 }
162 } else {
163 if ( in_array($wordLastVowel, $frontVowels) ) {
164 $word = implode("",$ar[0]) . "де";
165 } elseif ( in_array($wordLastVowel, $backVowels) ) {
166 $word = implode("",$ar[0]) . "да";
167 } else {
168 }
169 }
170 break;
171 case "ablative":
172 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
173 if ( in_array($wordLastVowel, $frontVowels) ) {
174 $word = implode("",$ar[0]) . "тен";
175 } elseif ( in_array($wordLastVowel, $backVowels) ) {
176 $word = implode("",$ar[0]) . "тан";
177 } else {
178 }
179 } else {
180 if ( in_array($wordLastVowel, $frontVowels) ) {
181 $word = implode("",$ar[0]) . "ден";
182 } elseif ( in_array($wordLastVowel, $backVowels) ) {
183 $word = implode("",$ar[0]) . "дан";
184 } else {
185 }
186 }
187 break;
188 case "directive1":
189 if ( in_array($wordEnding, $directiveVoicedStems) ) {
190 $word = implode("",$ar[0]) . "же";
191 } elseif ( in_array($wordEnding, $directiveUnvoicedStems) ) {
192 $word = implode("",$ar[0]) . "че";
193 } else {
194 }
195 break;
196 case "directive2":
197 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
198 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
199 $word = implode("",$ar[0]) . "түве";
200 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
201 $word = implode("",$ar[0]) . "тиве";
202 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
203 $word = implode("",$ar[0]) . "туве";
204 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
205 $word = implode("",$ar[0]) . "тыве";
206 } else {
207 }
208 } else {
209 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
210 $word = implode("",$ar[0]) . "дүве";
211 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
212 $word = implode("",$ar[0]) . "диве";
213 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
214 $word = implode("",$ar[0]) . "дуве";
215 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
216 $word = implode("",$ar[0]) . "дыве";
217 } else {
218 }
219 }
220 break;
221 default:
222 break;
223 }
224 return $word;
225 }
226 }