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