MediaWiki master
LanguageTyv.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Languages;
8
12
20class LanguageTyv extends Language {
21
23 public function convertGrammar( $word, $case ) {
24 $grammarForms =
26 if ( isset( $grammarForms['tyv'][$case][$word] ) ) {
27 return $grammarForms['tyv'][$case][$word];
28 }
29
30 // Set up some constants...
31 $allVowels = [ "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я" ];
32 $frontVowels = [ "е", "и", "э", "ө", "ү" ];
33 $backVowels = [ "а", "ё", "о", "у", "ы", "ю", "я" ];
34 $unroundFrontVowels = [ "е", "и", "э" ];
35 $roundFrontVowels = [ "ө", "ү" ];
36 $unroundBackVowels = [ "а", "ы", "я" ];
37 $roundBackVowels = [ "ё", "о", "у", "ю" ];
38 $unvoicedPhonemes = [ "т", "п", "с", "ш", "к", "ч", "х" ];
39 $directiveUnvoicedStems = [ "т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң" ];
40 $directiveVoicedStems = [ "д", "б", "з", "ж", "г", "р", "й" ];
41
42 // Put the word in a form we can play with since we're using UTF-8
43 $ar = mb_str_split( $word, 1 );
44
45 // Here's the last letter in the word
46 $wordEnding = end( $ar );
47
48 // Find the last vowel in the word
49 $wordLastVowel = null;
50 for ( $i = count( $ar ); $i--; ) {
51 if ( in_array( $ar[$i], $allVowels, true ) ) {
52 $wordLastVowel = $ar[$i];
53 break;
54 }
55 }
56
57 // Now convert the word
58 switch ( $case ) {
59 case "genitive":
60 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
61 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
62 $word .= "түң";
63 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
64 $word .= "тиң";
65 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
66 $word .= "туң";
67 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
68 $word .= "тың";
69 }
70 } elseif ( $wordEnding === "л" ) {
71 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
72 $word .= "дүң";
73 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
74 $word .= "диң";
75 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
76 $word .= "дуң";
77 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
78 $word .= "дың";
79 }
80 } else {
81 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
82 $word .= "нүң";
83 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
84 $word .= "ниң";
85 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
86 $word .= "нуң";
87 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
88 $word .= "ның";
89 }
90 }
91 break;
92
93 case "dative":
94 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
95 if ( in_array( $wordLastVowel, $frontVowels ) ) {
96 $word .= "ке";
97 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
98 $word .= "ка";
99 }
100 } else {
101 if ( in_array( $wordLastVowel, $frontVowels ) ) {
102 $word .= "ге";
103 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
104 $word .= "га";
105 }
106 }
107 break;
108
109 case "accusative":
110 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
111 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
112 $word .= "тү";
113 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
114 $word .= "ти";
115 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
116 $word .= "ту";
117 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
118 $word .= "ты";
119 }
120 } elseif ( $wordEnding === "л" ) {
121 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
122 $word .= "дү";
123 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
124 $word .= "ди";
125 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
126 $word .= "ду";
127 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
128 $word .= "ды";
129 }
130 } else {
131 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
132 $word .= "нү";
133 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
134 $word .= "ни";
135 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
136 $word .= "ну";
137 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
138 $word .= "ны";
139 }
140 }
141 break;
142
143 case "locative":
144 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
145 if ( in_array( $wordLastVowel, $frontVowels ) ) {
146 $word .= "те";
147 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
148 $word .= "та";
149 }
150 } else {
151 if ( in_array( $wordLastVowel, $frontVowels ) ) {
152 $word .= "де";
153 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
154 $word .= "да";
155 }
156 }
157 break;
158
159 case "ablative":
160 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
161 if ( in_array( $wordLastVowel, $frontVowels ) ) {
162 $word .= "тен";
163 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
164 $word .= "тан";
165 }
166 } else {
167 if ( in_array( $wordLastVowel, $frontVowels ) ) {
168 $word .= "ден";
169 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
170 $word .= "дан";
171 }
172 }
173 break;
174
175 case "directive1":
176 if ( in_array( $wordEnding, $directiveVoicedStems ) ) {
177 $word .= "же";
178 } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) {
179 $word .= "че";
180 }
181 break;
182
183 case "directive2":
184 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
185 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
186 $word .= "түве";
187 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
188 $word .= "тиве";
189 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
190 $word .= "туве";
191 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
192 $word .= "тыве";
193 }
194 } else {
195 if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
196 $word .= "дүве";
197 } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
198 $word .= "диве";
199 } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
200 $word .= "дуве";
201 } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
202 $word .= "дыве";
203 }
204 }
205 break;
206
207 default:
208 break;
209 }
210
211 return $word;
212 }
213}
214
216class_alias( LanguageTyv::class, 'LanguageTyv' );
Base class for language-specific code.
Definition Language.php:68
Tyvan localization (Тыва дыл)
convertGrammar( $word, $case)
Grammatical transformations, needed for inflected languages Invoked by putting {{grammar:case|word}} ...
A class containing constants representing the names of configuration variables.
const GrammarForms
Name constant for the GrammarForms setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.