3 /** Ukrainian (українська мова)
7 class LanguageUk
extends Language
{
8 # Convert from the nominative form of a noun to some other case
9 # Invoked with {{grammar:case|word}}
10 function convertGrammar( $word, $case ) {
11 global $wgGrammarForms;
12 if ( isset($wgGrammarForms['uk'][$case][$word]) ) {
13 return $wgGrammarForms['uk'][$case][$word];
16 # These rules are not perfect, but they are currently only used for site names so it doesn't
17 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
19 #join and array_slice instead mb_substr
21 preg_match_all( '/./us', $word, $ar );
22 if (!preg_match("/[a-zA-Z_]/us", $word))
24 case 'genitive': #родовий відмінок
25 if ((join('',array_slice($ar[0],-4))=='вікі') ||
(join('',array_slice($ar[0],-4))=='Вікі'))
27 elseif (join('',array_slice($ar[0],-1))=='ь')
28 $word = join('',array_slice($ar[0],0,-1)).'я';
29 elseif (join('',array_slice($ar[0],-2))=='ія')
30 $word=join('',array_slice($ar[0],0,-2)).'ії';
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],-3))=='ник')
38 $word=join('',array_slice($ar[0],0,-3)).'ника';
40 case 'dative': #давальний відмінок
43 case 'accusative': #знахідний відмінок
44 if ((join('',array_slice($ar[0],-4))=='вікі') ||
(join('',array_slice($ar[0],-4))=='Вікі'))
46 elseif (join('',array_slice($ar[0],-2))=='ія')
47 $word=join('',array_slice($ar[0],0,-2)).'ію';
49 case 'instrumental': #орудний відмінок
52 case 'prepositional': #місцевий відмінок
59 function convertPlural( $count, $forms ) {
60 if ( !count($forms) ) { return ''; }
62 //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
63 if( count($forms) === 2 ) return $count == 1 ?
$forms[0] : $forms[1];
65 // FIXME: CLDR defines 4 plural forms. Form for decimals is missing/
66 // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#uk
67 $forms = $this->preConvertPlural( $forms, 3 );
69 if ($count > 10 && floor(($count %
100) / 10) == 1) {
72 switch ($count %
10) {
73 case 1: return $forms[0];
76 case 4: return $forms[1];
77 default: return $forms[2];
83 * Ukrainian numeric format is "12 345,67" but "1234,56"
86 function commafy($_) {
87 if (!preg_match('/^\d{1,4}$/',$_)) {
88 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));