remove EOL whitespace, and excess empty lines
[lhc/web/wiklou.git] / languages / classes / LanguageUk.php
1 <?php
2 /** Ukrainian (українська мова)
3 *
4 * @addtogroup Language
5 */
6
7 /* Please, see Language.php for general function comments */
8 class LanguageUk extends Language {
9 # Convert from the nominative form of a noun to some other case
10 # Invoked with {{grammar:case|word}}
11 function convertGrammar( $word, $case ) {
12 global $wgGrammarForms;
13 if ( isset($wgGrammarForms['uk'][$case][$word]) ) {
14 return $wgGrammarForms['uk'][$case][$word];
15 }
16
17 # These rules are not perfect, but they are currently only used for site names so it doesn't
18 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
19
20 #join and array_slice instead mb_substr
21 $ar = array();
22 preg_match_all( '/./us', $word, $ar );
23 if (!preg_match("/[a-zA-Z_]/us", $word))
24 switch ( $case ) {
25 case 'genitive': #родовий відмінок
26 if ((join('',array_slice($ar[0],-4))=='вікі') || (join('',array_slice($ar[0],-4))=='Вікі'))
27 {}
28 elseif (join('',array_slice($ar[0],-1))=='ь')
29 $word = join('',array_slice($ar[0],0,-1)).'я';
30 elseif (join('',array_slice($ar[0],-2))=='ія')
31 $word=join('',array_slice($ar[0],0,-2)).'ії';
32 elseif (join('',array_slice($ar[0],-2))=='ка')
33 $word=join('',array_slice($ar[0],0,-2)).'ки';
34 elseif (join('',array_slice($ar[0],-2))=='ти')
35 $word=join('',array_slice($ar[0],0,-2)).'тей';
36 elseif (join('',array_slice($ar[0],-2))=='ди')
37 $word=join('',array_slice($ar[0],0,-2)).'дів';
38 elseif (join('',array_slice($ar[0],-3))=='ник')
39 $word=join('',array_slice($ar[0],0,-3)).'ника';
40 break;
41 case 'dative': #давальний відмінок
42 #stub
43 break;
44 case 'accusative': #знахідний відмінок
45 if ((join('',array_slice($ar[0],-4))=='вікі') || (join('',array_slice($ar[0],-4))=='Вікі'))
46 {}
47 elseif (join('',array_slice($ar[0],-2))=='ія')
48 $word=join('',array_slice($ar[0],0,-2)).'ію';
49 break;
50 case 'instrumental': #орудний відмінок
51 #stub
52 break;
53 case 'prepositional': #місцевий відмінок
54 #stub
55 break;
56 }
57 return $word;
58 }
59
60 function convertPlural( $count, $forms ) {
61 if ( !count($forms) ) { return ''; }
62 $forms = $this->preConvertPlural( $forms, 3 );
63
64 if ($count > 10 && floor(($count % 100) / 10) == 1) {
65 return $forms[2];
66 } else {
67 switch ($count % 10) {
68 case 1: return $forms[0];
69 case 2:
70 case 3:
71 case 4: return $forms[1];
72 default: return $forms[2];
73 }
74 }
75 }
76
77 /*
78 * Ukrainian numeric format is "12 345,67" but "1234,56"
79 */
80
81 function commafy($_) {
82 if (!preg_match('/^\d{1,4}$/',$_)) {
83 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
84 } else {
85 return $_;
86 }
87 }
88 }