* (bug 12145) Update Kazakh translations
[lhc/web/wiklou.git] / languages / classes / LanguageKk_kz.php
1 <?php
2 /** Kazakh (Қазақша)
3 *
4 *
5 * @addtogroup Language
6 */
7
8
9 class LanguageKk_kz extends Language {
10
11 # Convert from the nominative form of a noun to some other case
12 # Invoked with {{GRAMMAR:case|word}}
13 /**
14 * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
15 */
16 function convertGrammar( $word, $case ) {
17 global $wgGrammarForms;
18 if ( isset( $wgGrammarForms['kk'][$case][$word] ) ) {
19 return $wgGrammarForms['kk'][$case][$word];
20 }
21 // Set up some constants...
22 // Vowels in last syllable
23 $frontVowels = array( "е", "ө", "ү", "і", "ә", "э" );
24 $backVowels = array( "а", "о", "ұ", "ы", "я", "ё" );
25 $allVowels = array( "е", "ө", "ү", "і", "ә", "э", "а", "о", "ұ", "ы", "я", "ё" );
26 // Preceding letters
27 $preVowels = $allVowels;
28 $preNasals = array( "м", "н", "ң" );
29 $preSonants = array( "и", "й", "л", "р", "у", "ю");
30 # $preVoiceds = array( "б", "в", "г", "ғ", "д", "ж", "з", "һ" );
31 # $preVoicelesses = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ" );
32 $preConsonants = array( "п", "ф", "к", "қ", "т", "ш", "с", "х", "ц", "ч", "щ", "б", "в", "г", "д" );
33 $preEzhZet = array( "ж", "з" );
34 $preSonorants = array( "и", "й", "л", "р", "у", "ю", "м", "н", "ң", "ж", "з");
35
36 // Possessives
37 $firsts = array( "м", "ң" ); // 1st singular, 2nd unformal
38 $seconds = array( "з" ); // 1st plural, 2nd formal
39 $thirds = array( "ы", "і" ); // 3rd
40
41 // Put the word in a form we can play with since we're using UTF-8
42 $ar = array();
43 $ar = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY);
44 $wordEnding = $ar[count( $ar ) - 1]; //Here's the last letter in the word
45 $wordReversed = array_reverse( $ar ); //Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug*
46
47 // Find the last vowel in the word
48 $wordLastVowel = NULL;
49 foreach ( $wordReversed as $xvalue ) {
50 foreach ( $allVowels as $yvalue ) {
51 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
52 $wordLastVowel = $xvalue;
53 break;
54 } else {
55 continue;
56 }
57 }
58 if ( $wordLastVowel !== NULL ) {
59 break;
60 } else {
61 continue;
62 }
63 }
64
65 // Now convert the word
66 switch ( $case ) {
67 case "dc1":
68 case "genitive": #ilik
69 if ( in_array( $wordEnding, $preConsonants ) ) {
70 if ( in_array( $wordLastVowel, $frontVowels ) ) {
71 $word = implode( "", $ar ) . "тің";
72 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
73 $word = implode( "", $ar ) . "тың";
74 }
75 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) ) {
76 if ( in_array( $wordLastVowel, $frontVowels ) ) {
77 $word = implode( "", $ar ) . "нің";
78 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
79 $word = implode( "", $ar ) . "ның";
80 }
81 } elseif ( in_array( $wordEnding, $preSonants ) || in_array( $wordEnding, $preEzhZet )) {
82 if ( in_array( $wordLastVowel, $frontVowels ) ) {
83 $word = implode( "", $ar ) . "дің";
84 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
85 $word = implode( "", $ar ) . "дың";
86 }
87 }
88 break;
89 case "dc2":
90 case "dative": #barıs
91 if ( in_array( $wordEnding, $preConsonants ) ) {
92 if ( in_array( $wordLastVowel, $frontVowels ) ) {
93 $word = implode( "", $ar ) . "ке";
94 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
95 $word = implode( "", $ar ) . "қа";
96 }
97 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
98 if ( in_array( $wordLastVowel, $frontVowels ) ) {
99 $word = implode( "", $ar ) . "ге";
100 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
101 $word = implode( "", $ar ) . "ға";
102 }
103 }
104 break;
105 case "dc21":
106 case "possessive dative": #täweldık + barıs
107 if ( in_array( $wordEnding, $firsts ) ) {
108 if ( in_array( $wordLastVowel, $frontVowels ) ) {
109 $word = implode( "", $ar ) . "е";
110 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
111 $word = implode( "", $ar ) . "а";
112 }
113 } elseif ( in_array( $wordEnding, $seconds ) ) {
114 if ( in_array( $wordLastVowel, $frontVowels ) ) {
115 $word = implode( "", $ar ) . "ге";
116 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
117 $word = implode( "", $ar ) . "ға";
118 }
119 } elseif ( in_array( $wordEnding, $thirds ) ) {
120 if ( in_array( $wordLastVowel, $frontVowels ) ) {
121 $word = implode( "", $ar ) . "не";
122 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
123 $word = implode( "", $ar ) . "на";
124 }
125 }
126 break;
127 case "dc3":
128 case "accusative": #tabıs
129 if ( in_array( $wordEnding, $preConsonants ) ) {
130 if ( in_array( $wordLastVowel, $frontVowels ) ) {
131 $word = implode( "", $ar ) . "ті";
132 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
133 $word = implode( "", $ar ) . "ты";
134 }
135 } elseif ( in_array( $wordEnding, $preVowels ) ) {
136 if ( in_array($wordLastVowel, $frontVowels ) ) {
137 $word = implode( "", $ar ) . "ні";
138 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
139 $word = implode( "", $ar ) . "ны";
140 }
141 } elseif ( in_array( $wordEnding, $preSonorants) ) {
142 if ( in_array( $wordLastVowel, $frontVowels) ) {
143 $word = implode( "", $ar ) . "ді";
144 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
145 $word = implode( "", $ar ) . "ды";
146 }
147 }
148 break;
149 case "dc31":
150 case "possessive accusative": #täweldık + tabıs
151 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
152 if ( in_array( $wordLastVowel, $frontVowels ) ) {
153 $word = implode( "", $ar ) . "ді";
154 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
155 $word = implode( "", $ar ) . "ды";
156 }
157 } elseif ( in_array( $wordEnding, $thirds ) ) {
158 $word = implode( "", $ar ) . "н";
159 }
160 break;
161 case "dc4":
162 case "locative": #jatıs
163 if ( in_array( $wordEnding, $preConsonants ) ) {
164 if ( in_array( $wordLastVowel, $frontVowels ) ) {
165 $word = implode( "", $ar ) . "те";
166 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
167 $word = implode( "", $ar ) . "та";
168 }
169 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preSonorants ) ) {
170 if ( in_array( $wordLastVowel, $frontVowels) ) {
171 $word = implode( "", $ar ) . "де";
172 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
173 $word = implode( "",$ar ) . "да";
174 }
175 }
176 break;
177 case "dc41":
178 case "possessive locative": #täweldık + jatıs
179 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $seconds ) ) {
180 if ( in_array( $wordLastVowel, $frontVowels ) ) {
181 $word = implode( "", $ar ) . "де";
182 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
183 $word = implode( "", $ar ) . "да";
184 }
185 } elseif ( in_array( $wordEnding, $thirds ) ) {
186 if ( in_array( $wordLastVowel, $frontVowels) ) {
187 $word = implode( "", $ar ) . "нде";
188 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
189 $word = implode( "",$ar ) . "нда";
190 }
191 }
192 break;
193 case "dc5":
194 case "ablative": #şığıs
195 if ( in_array( $wordEnding, $preConsonants ) ) {
196 if ( in_array( $wordLastVowel, $frontVowels ) ) {
197 $word = implode( "", $ar ) . "тен";
198 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
199 $word = implode( "", $ar ) . "тан";
200 }
201 } elseif ( in_array($wordEnding, $preVowels ) || in_array($wordEnding, $preSonants ) || in_array($wordEnding, $preEzhZet ) ) {
202 if ( in_array( $wordLastVowel, $frontVowels ) ) {
203 $word = implode( "", $ar ) . "ден";
204 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
205 $word = implode( "", $ar ) . "дан";
206 }
207 } elseif ( in_array($wordEnding, $preNasals ) ) {
208 if ( in_array( $wordLastVowel, $frontVowels ) ) {
209 $word = implode( "", $ar ) . "нен";
210 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
211 $word = implode( "", $ar ) . "нан";
212 }
213 }
214 break;
215 case "dc51":
216 case "possessive ablative": #täweldık + şığıs
217 if ( in_array( $wordEnding, $firsts ) || in_array( $wordEnding, $thirds ) ) {
218 if ( in_array( $wordLastVowel, $frontVowels ) ) {
219 $word = implode( "", $ar ) . "нен";
220 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
221 $word = implode( "", $ar ) . "нан";
222 }
223 } elseif ( in_array($wordEnding, $seconds ) ) {
224 if ( in_array( $wordLastVowel, $frontVowels ) ) {
225 $word = implode( "", $ar ) . "ден";
226 } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
227 $word = implode( "", $ar ) . "дан";
228 }
229 }
230 break;
231 case "dc6":
232 case "comitative": #kömektes
233 if ( in_array( $wordEnding, $preConsonants ) ) {
234 $word = implode( "", $ar ) . "пен";
235 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
236 $word = implode( "", $ar ) . "мен";
237 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
238 $word = implode( "", $ar ) . "бен";
239 }
240 break;
241 case "dc61":
242 case "possessive comitative": #täweldık + kömektes
243 if ( in_array( $wordEnding, $preConsonants ) ) {
244 $word = implode( "", $ar ) . "пенен";
245 } elseif ( in_array( $wordEnding, $preVowels ) || in_array( $wordEnding, $preNasals ) || in_array( $wordEnding, $preSonants ) ) {
246 $word = implode( "", $ar ) . "менен";
247 } elseif ( in_array( $wordEnding, $preEzhZet ) ) {
248 $word = implode( "", $ar ) . "бенен";
249 }
250 break;
251 default: #dc0 #nominative #ataw
252 }
253 return $word;
254 }
255
256 function ucfirst ( $string ) {
257 if ( $string[0] == 'i' ) {
258 return 'İ' . substr( $string, 1 );
259 } else {
260 return parent::ucfirst( $string );
261 }
262 }
263
264 /**
265 * Avoid grouping whole numbers between 0 to 9999
266 */
267 function commafy( $_ ) {
268 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
269 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
270 } else {
271 return $_;
272 }
273 }
274 }
275
276
277