2 /** Ukrainian (українська мова)
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];
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.
21 #join and array_slice instead mb_substr
23 preg_match_all( '/./us', $word, $ar );
24 if (!preg_match("/[a-zA-Z_]/us", $word))
26 case 'genitive': #родовий відмінок
27 if ((join('',array_slice($ar[0],-4))=='вікі') ||
(join('',array_slice($ar[0],-4))=='Вікі'))
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)).'ника';
42 case 'dative': #давальний відмінок
45 case 'accusative': #знахідний відмінок
46 if ((join('',array_slice($ar[0],-4))=='вікі') ||
(join('',array_slice($ar[0],-4))=='Вікі'))
48 elseif (join('',array_slice($ar[0],-2))=='ія')
49 $word=join('',array_slice($ar[0],0,-2)).'ію';
51 case 'instrumental': #орудний відмінок
54 case 'prepositional': #місцевий відмінок
61 function convertPlural( $count, $forms ) {
62 if ( !count($forms) ) { return ''; }
63 $forms = $this->preConvertPlural( $forms, 3 );
65 if ($count > 10 && floor(($count %
100) / 10) == 1) {
68 switch ($count %
10) {
69 case 1: return $forms[0];
72 case 4: return $forms[1];
73 default: return $forms[2];
79 * Ukrainian numeric format is "12 345,67" but "1234,56"
82 function commafy($_) {
83 if (!preg_match('/^\d{1,4}$/',$_)) {
84 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));