Localisation updates from https://translatewiki.net.
[mediawiki.git] / languages / classes / LanguageTyv.php
blob429d0a628b1c5196492a98a0b79e29dc4eaa693b
1 <?php
2 /**
3 * Tyvan (Тыва дыл) specific code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Language
24 /**
25 * Tyvan localization (Тыва дыл)
27 * From friends at tyvawiki.org
29 * @ingroup Language
31 class LanguageTyv extends Language {
32 /**
33 * Grammatical transformations, needed for inflected languages
34 * Invoked by putting {{grammar:case|word}} in a message
36 * @param string $word
37 * @param string $case
38 * @return string
40 function convertGrammar( $word, $case ) {
41 global $wgGrammarForms;
42 if ( isset( $wgGrammarForms['tyv'][$case][$word] ) ) {
43 return $wgGrammarForms['tyv'][$case][$word];
46 // Set up some constants...
47 $allVowels = array( "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы",
48 "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y" );
49 $frontVowels = array( "е", "и", "э", "ө", "ү", "e", "i", "ö", "ü" );
50 $backVowels = array( "а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y" );
51 $unroundFrontVowels = array( "е", "и", "э", "e", "i" );
52 $roundFrontVowels = array( "ө", "ү", "ö", "ü" );
53 $unroundBackVowels = array( "а", "ы", "я", "a", "y" );
54 $roundBackVowels = array( "ё", "о", "у", "ю", "o", "u" );
55 //$voicedPhonemes = array( "д", "б", "з", "ж", "г", "d", "b", "z", "g" );
56 $unvoicedPhonemes = array( "т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x" );
57 $directiveUnvoicedStems = array( "т", "п", "с", "ш", "к", "ч", "х", "л",
58 "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ" );
59 $directiveVoicedStems = array( "д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j" );
61 //$allSonants = array("л", "м", "н", "ң", "р", "й");
62 //$allNasals = array("м", "н", "ң");
64 //Put the word in a form we can play with since we're using UTF-8
65 preg_match_all( '/./us', $word, $ar );
67 // Here's the last letter in the word
68 $wordEnding = $ar[0][count( $ar[0] ) - 1];
69 // Here's an array with the order of the letters in the word reversed so
70 // we can find a match quicker. *shrug*
71 $wordReversed = array_reverse( $ar[0] );
73 // Find the last vowel in the word
74 $wordLastVowel = null;
75 foreach ( $wordReversed as $xvalue ) {
76 foreach ( $allVowels as $yvalue ) {
77 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
78 $wordLastVowel = $xvalue;
79 break;
80 } else {
81 continue;
84 if ( $wordLastVowel !== null ) {
85 break;
86 } else {
87 continue;
91 // Now convert the word
92 switch ( $case ) {
93 case "genitive":
94 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
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 {
105 } elseif ( $wordEnding === "л" || $wordEnding === "l" ) {
106 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
107 $word = implode( "", $ar[0] ) . "дүң";
108 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
109 $word = implode( "", $ar[0] ) . "диң";
110 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
111 $word = implode( "", $ar[0] ) . "дуң";
112 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
113 $word = implode( "", $ar[0] ) . "дың";
114 } else {
116 } else {
117 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
118 $word = implode( "", $ar[0] ) . "нүң";
119 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
120 $word = implode( "", $ar[0] ) . "ниң";
121 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
122 $word = implode( "", $ar[0] ) . "нуң";
123 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
124 $word = implode( "", $ar[0] ) . "ның";
125 } else {
128 break;
129 case "dative":
130 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
131 if ( in_array( $wordLastVowel, $frontVowels ) ) {
132 $word = implode( "", $ar[0] ) . "ке";
133 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
134 $word = implode( "", $ar[0] ) . "ка";
135 } else {
137 } else {
138 if ( in_array( $wordLastVowel, $frontVowels ) ) {
139 $word = implode( "", $ar[0] ) . "ге";
140 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
141 $word = implode( "", $ar[0] ) . "га";
142 } else {
145 break;
146 case "accusative":
147 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
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 {
158 } elseif ( $wordEnding === "л" || $wordEnding === "l" ) {
159 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
160 $word = implode( "", $ar[0] ) . "дү";
161 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
162 $word = implode( "", $ar[0] ) . "ди";
163 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
164 $word = implode( "", $ar[0] ) . "ду";
165 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
166 $word = implode( "", $ar[0] ) . "ды";
167 } else {
169 } else {
170 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
171 $word = implode( "", $ar[0] ) . "нү";
172 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
173 $word = implode( "", $ar[0] ) . "ни";
174 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
175 $word = implode( "", $ar[0] ) . "ну";
176 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
177 $word = implode( "", $ar[0] ) . "ны";
178 } else {
181 break;
182 case "locative":
183 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
184 if ( in_array( $wordLastVowel, $frontVowels ) ) {
185 $word = implode( "", $ar[0] ) . "те";
186 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
187 $word = implode( "", $ar[0] ) . "та";
188 } else {
190 } else {
191 if ( in_array( $wordLastVowel, $frontVowels ) ) {
192 $word = implode( "", $ar[0] ) . "де";
193 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
194 $word = implode( "", $ar[0] ) . "да";
195 } else {
198 break;
199 case "ablative":
200 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
201 if ( in_array( $wordLastVowel, $frontVowels ) ) {
202 $word = implode( "", $ar[0] ) . "тен";
203 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
204 $word = implode( "", $ar[0] ) . "тан";
205 } else {
207 } else {
208 if ( in_array( $wordLastVowel, $frontVowels ) ) {
209 $word = implode( "", $ar[0] ) . "ден";
210 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
211 $word = implode( "", $ar[0] ) . "дан";
212 } else {
215 break;
216 case "directive1":
217 if ( in_array( $wordEnding, $directiveVoicedStems ) ) {
218 $word = implode( "", $ar[0] ) . "же";
219 } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) {
220 $word = implode( "", $ar[0] ) . "че";
221 } else {
223 break;
224 case "directive2":
225 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
226 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
227 $word = implode( "", $ar[0] ) . "түве";
228 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
229 $word = implode( "", $ar[0] ) . "тиве";
230 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
231 $word = implode( "", $ar[0] ) . "туве";
232 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
233 $word = implode( "", $ar[0] ) . "тыве";
234 } else {
236 } else {
237 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
238 $word = implode( "", $ar[0] ) . "дүве";
239 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
240 $word = implode( "", $ar[0] ) . "диве";
241 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
242 $word = implode( "", $ar[0] ) . "дуве";
243 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
244 $word = implode( "", $ar[0] ) . "дыве";
245 } else {
248 break;
249 default:
250 break;
252 return $word;