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