00001 <?php 00002 00007 class LanguageCu extends Language { 00008 # Convert from the nominative form of a noun to some other case 00009 # Invoked with {{grammar:case|word}} 00010 function convertGrammar( $word, $case ) { 00011 global $wgGrammarForms; 00012 if ( isset($wgGrammarForms['сu'][$case][$word]) ) { 00013 return $wgGrammarForms['сu'][$case][$word]; 00014 } 00015 00016 # These rules are not perfect, but they are currently only used for site names so it doesn't 00017 # matter if they are wrong sometimes. Just add a special case for your site name if necessary. 00018 00019 #join and array_slice instead mb_substr 00020 $ar = array(); 00021 preg_match_all( '/./us', $word, $ar ); 00022 if (!preg_match("/[a-zA-Z_]/us", $word)) 00023 switch ( $case ) { 00024 case 'genitive': #родительный падеж 00025 if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики')) 00026 {} 00027 elseif (join('',array_slice($ar[0],-2))=='ї') 00028 $word = join('',array_slice($ar[0],0,-2)).'їѩ'; 00029 break; 00030 case 'accusative': #винительный падеж 00031 #stub 00032 break; 00033 } 00034 return $word; 00035 } 00036 00037 function convertPlural( $count, $forms ) { 00038 if ( !count($forms) ) { return ''; } 00039 $forms = $this->preConvertPlural( $forms, 4 ); 00040 00041 switch ($count % 10) { 00042 case 1: return $forms[0]; 00043 case 2: return $forms[1]; 00044 case 3: 00045 case 4: return $forms[2]; 00046 default: return $forms[3]; 00047 } 00048 } 00049 }