Using __construct for all the language constructors, and few minor fixes.
[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 # Originally based upon LanguageRu.php
9
10 require_once( 'LanguageUtf8.php' );
11
12 #--------------------------------------------------------------------------
13 # Language-specific text
14 #--------------------------------------------------------------------------
15
16 /* private */ $wgNamespaceNamesTyv = array(
17 NS_MEDIA => 'Медиа', //Media
18 NS_SPECIAL => 'Тускай', //Special
19 NS_MAIN => '',
20 NS_TALK => 'Чугаа', //Talk
21 NS_USER => 'Aжыглакчы', //User
22 NS_USER_TALK => 'Aжыглакчы_чугаа', //User_talk
23 NS_PROJECT => $wgMetaNamespace,
24 NS_PROJECT_TALK => $wgMetaNamespace . '_чугаа', //_talk
25 NS_IMAGE => 'Чурук', //Image
26 NS_IMAGE_TALK => 'Чурук_чугаа', //Image_talk
27 NS_MEDIAWIKI => 'МедиаВики', //MediaWiki
28 NS_MEDIAWIKI_TALK => 'МедиаВики_чугаа', //MediaWiki_talk
29 NS_TEMPLATE => 'Хээ', //Template
30 NS_TEMPLATE_TALK => 'Хээ_чугаа', //Template_talk
31 NS_HELP => 'Дуза', //Help
32 NS_HELP_TALK => 'Дуза_чугаа', //Help_talk
33 NS_CATEGORY => 'Бөлүк', //Category
34 NS_CATEGORY_TALK => 'Бөлүк_чугаа', //Category_talk
35 ) + $wgNamespaceNamesEn;
36
37 /* private */ $wgSkinNamesTyv = array(
38 'standard' => 'Classic', //Classic
39 'nostalgia' => 'Nostalgia', //Nostalgia
40 'cologneblue' => 'Cologne Blue', //Cologne Blue
41 'davinci' => 'ДаВинчи', //DaVinci
42 'mono' => 'Моно', //Mono
43 'monobook' => 'Моно-Ном', //MonoBook
44 'myskin' => 'MySkin', //MySkin
45 'chick' => 'Chick' //Chick
46 ) + $wgSkinNamesEn;
47
48 /* private */ $wgBookstoreListTyv = array(
49 'ОЗОН' => 'http://www.ozon.ru/?context=advsearch_book&isbn=$1',
50 'Books.Ru' => 'http://www.books.ru/shop/search/advanced?as%5Btype%5D=books&as%5Bname%5D=&as%5Bisbn%5D=$1&as%5Bauthor%5D=&as%5Bmaker%5D=&as%5Bcontents%5D=&as%5Binfo%5D=&as%5Bdate_after%5D=&as%5Bdate_before%5D=&as%5Bprice_less%5D=&as%5Bprice_more%5D=&as%5Bstrict%5D=%E4%E0&as%5Bsub%5D=%E8%F1%EA%E0%F2%FC&x=22&y=8',
51 'Яндекс.Маркет' => 'http://market.yandex.ru/search.xml?text=$1',
52 'Amazon.com' => 'http://www.amazon.com/exec/obidos/ISBN=$1',
53 'AddALL' => 'http://www.addall.com/New/Partner.cgi?query=$1&type=ISBN',
54 'PriceSCAN' => 'http://www.pricescan.com/books/bookDetail.asp?isbn=$1',
55 'Barnes & Noble' => 'http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=$1'
56 );
57
58 if (!$wgCachedMessageArrays) {
59 require_once('MessagesTyv.php');
60 }
61
62
63 #--------------------------------------------------------------------------
64 # Internationalisation code
65 #--------------------------------------------------------------------------
66
67 class LanguageTyv extends LanguageUtf8 {
68 function __construct() {
69 global $wgNamespaceNamesTyv, $wgMetaNamespace;
70 parent::__construct();
71 $wgNamespaceNamesTyv[NS_PROJECT_TALK] = $wgMetaNamespace . '_чугаа';
72 }
73
74 function getNamespaces() {
75 global $wgNamespaceNamesTyv;
76 return $wgNamespaceNamesTyv;
77 }
78
79 function getSkinNames() {
80 global $wgSkinNamesTyv;
81 return $wgSkinNamesTyv;
82 }
83
84 function getMessage( $key ) {
85 global $wgAllMessagesTyv;
86 return isset($wgAllMessagesTyv[$key]) ? $wgAllMessagesTyv[$key] : parent::getMessage($key);
87 }
88
89 function fallback8bitEncoding() {
90 return "windows-1251";
91 }
92
93 /**
94 * Grammatical transformations, needed for inflected languages
95 * Invoked by putting {{grammar:case|word}} in a message
96 *
97 * @param string $word
98 * @param string $case
99 * @return string
100 */
101 function convertGrammar( $word, $case ) {
102 global $wgGrammarForms;
103 if ( isset($wgGrammarForms['tyv'][$case][$word]) ) {
104 return $wgGrammarForms['tyv'][$case][$word];
105 }
106
107
108 // Set up some constants...
109 $allVowels = array("е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y");
110 $frontVowels = array("е", "и", "э", "ө", "ү", "e", "i", "ö", "ü");
111 $backVowels = array("а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y");
112 $unroundFrontVowels = array("е", "и", "э", "e", "i");
113 $roundFrontVowels = array("ө", "ү", "ö", "ü");
114 $unroundBackVowels = array("а", "ы", "я", "a", "y");
115 $roundBackVowels = array("ё", "о", "у", "ю", "o", "u");
116 $voicedPhonemes = array("д", "б", "з", "ж", "г", "d", "b", "z", "g");
117 $unvoicedPhonemes = array("т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x");
118 $directiveUnvoicedStems = array("т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ");
119 $directiveVoicedStems = array("д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j");
120
121 // $allSonants = array("л", "м", "н", "ң", "р", "й");
122 // $allNasals = array("м", "н", "ң");
123
124 // Put the word in a form we can play with since we're using UTF-8
125 preg_match_all( '/./us', $word, $ar );
126
127 $wordEnding = $ar[0][count($ar[0]) - 1]; //Here's the last letter in the word
128 $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*
129
130 // Find the last vowel in the word
131 $wordLastVowel = NULL;
132 foreach ( $wordReversed as $xvalue ) {
133 foreach ( $allVowels as $yvalue ) {
134 if ( strcmp($xvalue, $yvalue) == 0 ) {
135 $wordLastVowel = $xvalue;
136 break;
137 } else {
138 continue;
139 }
140 }
141 if ( $wordLastVowel !== NULL ) {
142 break;
143 } else {
144 continue;
145 }
146 }
147
148 // Now convert the word
149 switch ( $case ) {
150 case "genitive":
151 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
152 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
153 $word = implode("",$ar[0]) . "түң";
154 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
155 $word = implode("",$ar[0]) . "тиң";
156 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
157 $word = implode("",$ar[0]) . "туң";
158 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
159 $word = implode("",$ar[0]) . "тың";
160 } else {
161 }
162 } elseif ( $wordEnding === "л" || $wordEnding === "l") {
163 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
164 $word = implode("",$ar[0]) . "дүң";
165 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
166 $word = implode("",$ar[0]) . "диң";
167 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
168 $word = implode("",$ar[0]) . "дуң";
169 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
170 $word = implode("",$ar[0]) . "дың";
171 } else {
172 }
173 } else {
174 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
175 $word = implode("",$ar[0]) . "нүң";
176 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
177 $word = implode("",$ar[0]) . "ниң";
178 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
179 $word = implode("",$ar[0]) . "нуң";
180 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
181 $word = implode("",$ar[0]) . "ның";
182 } else {
183 }
184 }
185 break;
186 case "dative":
187 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
188 if ( in_array($wordLastVowel, $frontVowels) ) {
189 $word = implode("",$ar[0]) . "ке";
190 } elseif ( in_array($wordLastVowel, $backVowels) ) {
191 $word = implode("",$ar[0]) . "ка";
192 } else {
193 }
194 } else {
195 if ( in_array($wordLastVowel, $frontVowels) ) {
196 $word = implode("",$ar[0]) . "ге";
197 } elseif ( in_array($wordLastVowel, $backVowels) ) {
198 $word = implode("",$ar[0]) . "га";
199 } else {
200 }
201 }
202 break;
203 case "accusative":
204 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
205 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
206 $word = implode("",$ar[0]) . "тү";
207 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
208 $word = implode("",$ar[0]) . "ти";
209 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
210 $word = implode("",$ar[0]) . "ту";
211 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
212 $word = implode("",$ar[0]) . "ты";
213 } else {
214 }
215 } elseif ( $wordEnding === "л" || $wordEnding === "l") {
216 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
217 $word = implode("",$ar[0]) . "дү";
218 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
219 $word = implode("",$ar[0]) . "ди";
220 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
221 $word = implode("",$ar[0]) . "ду";
222 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
223 $word = implode("",$ar[0]) . "ды";
224 } else {
225 }
226 } else {
227 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
228 $word = implode("",$ar[0]) . "нү";
229 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
230 $word = implode("",$ar[0]) . "ни";
231 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
232 $word = implode("",$ar[0]) . "ну";
233 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
234 $word = implode("",$ar[0]) . "ны";
235 } else {
236 }
237 }
238 break;
239 case "locative":
240 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
241 if ( in_array($wordLastVowel, $frontVowels) ) {
242 $word = implode("",$ar[0]) . "те";
243 } elseif ( in_array($wordLastVowel, $backVowels) ) {
244 $word = implode("",$ar[0]) . "та";
245 } else {
246 }
247 } else {
248 if ( in_array($wordLastVowel, $frontVowels) ) {
249 $word = implode("",$ar[0]) . "де";
250 } elseif ( in_array($wordLastVowel, $backVowels) ) {
251 $word = implode("",$ar[0]) . "да";
252 } else {
253 }
254 }
255 break;
256 case "ablative":
257 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
258 if ( in_array($wordLastVowel, $frontVowels) ) {
259 $word = implode("",$ar[0]) . "тен";
260 } elseif ( in_array($wordLastVowel, $backVowels) ) {
261 $word = implode("",$ar[0]) . "тан";
262 } else {
263 }
264 } else {
265 if ( in_array($wordLastVowel, $frontVowels) ) {
266 $word = implode("",$ar[0]) . "ден";
267 } elseif ( in_array($wordLastVowel, $backVowels) ) {
268 $word = implode("",$ar[0]) . "дан";
269 } else {
270 }
271 }
272 break;
273 case "directive1":
274 if ( in_array($wordEnding, $directiveVoicedStems) ) {
275 $word = implode("",$ar[0]) . "же";
276 } elseif ( in_array($wordEnding, $directiveUnvoicedStems) ) {
277 $word = implode("",$ar[0]) . "че";
278 } else {
279 }
280 break;
281 case "directive2":
282 if ( in_array($wordEnding, $unvoicedPhonemes) ) {
283 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
284 $word = implode("",$ar[0]) . "түве";
285 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
286 $word = implode("",$ar[0]) . "тиве";
287 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
288 $word = implode("",$ar[0]) . "туве";
289 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
290 $word = implode("",$ar[0]) . "тыве";
291 } else {
292 }
293 } else {
294 if ( in_array($wordLastVowel, $roundFrontVowels) ) {
295 $word = implode("",$ar[0]) . "дүве";
296 } elseif ( in_array($wordLastVowel, $unroundFrontVowels) ) {
297 $word = implode("",$ar[0]) . "диве";
298 } elseif ( in_array($wordLastVowel, $roundBackVowels) ) {
299 $word = implode("",$ar[0]) . "дуве";
300 } elseif ( in_array($wordLastVowel, $unroundBackVowels) ) {
301 $word = implode("",$ar[0]) . "дыве";
302 } else {
303 }
304 }
305 break;
306 default:
307 break;
308 }
309 return $word;
310 }
311 }
312 ?>