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
25 * Tyvan localization (Тыва дыл)
27 * From friends at tyvawiki.org
31 class LanguageTyv
extends Language
{
33 * Grammatical transformations, needed for inflected languages
34 * Invoked by putting {{grammar:case|word}} in a message
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( "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y" );
48 $frontVowels = array( "е", "и", "э", "ө", "ү", "e", "i", "ö", "ü" );
49 $backVowels = array( "а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y" );
50 $unroundFrontVowels = array( "е", "и", "э", "e", "i" );
51 $roundFrontVowels = array( "ө", "ү", "ö", "ü" );
52 $unroundBackVowels = array( "а", "ы", "я", "a", "y" );
53 $roundBackVowels = array( "ё", "о", "у", "ю", "o", "u" );
54 //$voicedPhonemes = array( "д", "б", "з", "ж", "г", "d", "b", "z", "g" );
55 $unvoicedPhonemes = array( "т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x" );
56 $directiveUnvoicedStems = array( "т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ" );
57 $directiveVoicedStems = array( "д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j" );
59 //$allSonants = array("л", "м", "н", "ң", "р", "й");
60 //$allNasals = array("м", "н", "ң");
62 //Put the word in a form we can play with since we're using UTF-8
63 preg_match_all( '/./us', $word, $ar );
65 $wordEnding = $ar[0][count( $ar[0] ) - 1]; // Here's the last letter in the word
66 $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*
68 // Find the last vowel in the word
69 $wordLastVowel = NULL;
70 foreach ( $wordReversed as $xvalue ) {
71 foreach ( $allVowels as $yvalue ) {
72 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
73 $wordLastVowel = $xvalue;
79 if ( $wordLastVowel !== NULL ) {
86 // Now convert the word
89 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
90 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
91 $word = implode( "", $ar[0] ) . "түң";
92 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
93 $word = implode( "", $ar[0] ) . "тиң";
94 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
95 $word = implode( "", $ar[0] ) . "туң";
96 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
97 $word = implode( "", $ar[0] ) . "тың";
100 } elseif ( $wordEnding === "л" ||
$wordEnding === "l" ) {
101 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
102 $word = implode( "", $ar[0] ) . "дүң";
103 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
104 $word = implode( "", $ar[0] ) . "диң";
105 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
106 $word = implode( "", $ar[0] ) . "дуң";
107 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
108 $word = implode( "", $ar[0] ) . "дың";
112 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
113 $word = implode( "", $ar[0] ) . "нүң";
114 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
115 $word = implode( "", $ar[0] ) . "ниң";
116 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
117 $word = implode( "", $ar[0] ) . "нуң";
118 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
119 $word = implode( "", $ar[0] ) . "ның";
125 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
126 if ( in_array( $wordLastVowel, $frontVowels ) ) {
127 $word = implode( "", $ar[0] ) . "ке";
128 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
129 $word = implode( "", $ar[0] ) . "ка";
133 if ( in_array( $wordLastVowel, $frontVowels ) ) {
134 $word = implode( "", $ar[0] ) . "ге";
135 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
136 $word = implode( "", $ar[0] ) . "га";
142 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
143 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
144 $word = implode( "", $ar[0] ) . "тү";
145 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
146 $word = implode( "", $ar[0] ) . "ти";
147 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
148 $word = implode( "", $ar[0] ) . "ту";
149 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
150 $word = implode( "", $ar[0] ) . "ты";
153 } elseif ( $wordEnding === "л" ||
$wordEnding === "l" ) {
154 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
155 $word = implode( "", $ar[0] ) . "дү";
156 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
157 $word = implode( "", $ar[0] ) . "ди";
158 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
159 $word = implode( "", $ar[0] ) . "ду";
160 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
161 $word = implode( "", $ar[0] ) . "ды";
165 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
166 $word = implode( "", $ar[0] ) . "нү";
167 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
168 $word = implode( "", $ar[0] ) . "ни";
169 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
170 $word = implode( "", $ar[0] ) . "ну";
171 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
172 $word = implode( "", $ar[0] ) . "ны";
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] ) . "та";
186 if ( in_array( $wordLastVowel, $frontVowels ) ) {
187 $word = implode( "", $ar[0] ) . "де";
188 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
189 $word = implode( "", $ar[0] ) . "да";
195 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
196 if ( in_array( $wordLastVowel, $frontVowels ) ) {
197 $word = implode( "", $ar[0] ) . "тен";
198 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
199 $word = implode( "", $ar[0] ) . "тан";
203 if ( in_array( $wordLastVowel, $frontVowels ) ) {
204 $word = implode( "", $ar[0] ) . "ден";
205 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
206 $word = implode( "", $ar[0] ) . "дан";
212 if ( in_array( $wordEnding, $directiveVoicedStems ) ) {
213 $word = implode( "", $ar[0] ) . "же";
214 } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) {
215 $word = implode( "", $ar[0] ) . "че";
220 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
221 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
222 $word = implode( "", $ar[0] ) . "түве";
223 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
224 $word = implode( "", $ar[0] ) . "тиве";
225 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
226 $word = implode( "", $ar[0] ) . "туве";
227 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
228 $word = implode( "", $ar[0] ) . "тыве";
232 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
233 $word = implode( "", $ar[0] ) . "дүве";
234 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
235 $word = implode( "", $ar[0] ) . "диве";
236 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
237 $word = implode( "", $ar[0] ) . "дуве";
238 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
239 $word = implode( "", $ar[0] ) . "дыве";