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