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