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