]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - languages/classes/LanguageUk.php
MediaWiki 1.11.0
[autoinstalls/mediawiki.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, $wordform1, $wordform2, $wordform3, $w4, $w5) {
62                 $count = str_replace (' ', '', $count);
63                 if ($count > 10 && floor(($count % 100) / 10) == 1) {
64                         return $wordform3;
65                 } else {
66                         switch ($count % 10) {
67                                 case 1: return $wordform1;
68                                 case 2:
69                                 case 3:
70                                 case 4: return $wordform2;
71                                 default: return $wordform3;
72                         }
73                 }
74         }
75
76         /*
77          * Ukrainian numeric format is "12 345,67" but "1234,56"
78          */
79
80         function commafy($_) {
81                 if (!preg_match('/^\d{1,4}$/',$_)) {
82                         return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
83                 } else {
84                         return $_;
85                 }
86         }
87 }
88