MediaWiki  REL1_20
LanguageCu.php
Go to the documentation of this file.
00001 <?php
00029 class LanguageCu extends Language {
00030 
00039         function convertGrammar( $word, $case ) {
00040                 global $wgGrammarForms;
00041                 if ( isset( $wgGrammarForms['сu'][$case][$word] ) ) {
00042                         return $wgGrammarForms['сu'][$case][$word];
00043                 }
00044 
00045                 # These rules are not perfect, but they are currently only used for site names so it doesn't
00046                 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
00047 
00048                 # join and array_slice instead mb_substr
00049                 $ar = array();
00050                 preg_match_all( '/./us', $word, $ar );
00051                 if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
00052                         switch ( $case ) {
00053                                 case 'genitive': # родительный падеж
00054                                         if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вики' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) )
00055                                                 { }
00056                                         elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ї' )
00057                                                 $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ';
00058                                         break;
00059                                 case 'accusative': # винительный падеж
00060                                         # stub
00061                                         break;
00062                         }
00063                 return $word;
00064         }
00065 
00071         function convertPlural( $count, $forms ) {
00072                 if ( !count( $forms ) ) { return ''; }
00073                 $forms = $this->preConvertPlural( $forms, 4 );
00074 
00075                 switch ( $count % 10 ) {
00076                         case 1:  return $forms[0];
00077                         case 2:  return $forms[1];
00078                         case 3:
00079                         case 4:  return $forms[2];
00080                         default: return $forms[3];
00081                 }
00082         }
00083 }