MediaWiki  REL1_20
LanguageHy.php
Go to the documentation of this file.
00001 <?php
00030 class LanguageHy extends Language {
00031 
00040         function convertGrammar( $word, $case ) {
00041                 global $wgGrammarForms;
00042                 if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) {
00043                         return $wgGrammarForms['hy'][$case][$word];
00044                 }
00045 
00046                 # These rules are not perfect, but they are currently only used for site names so it doesn't
00047                 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
00048 
00049                 # join and array_slice instead mb_substr
00050                 $ar = array();
00051                 preg_match_all( '/./us', $word, $ar );
00052                 if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
00053                         switch ( $case ) {
00054                                 case 'genitive': # սեռական հոլով
00055                                         if ( join( '', array_slice( $ar[0], -1 ) ) == 'ա' )
00056                                                 $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'այի';
00057                                         elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ո' )
00058                                                 $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի';
00059                                         elseif ( join( '', array_slice( $ar[0], -4 ) ) == 'գիրք' )
00060                                                 $word = join( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի';
00061                                         else
00062                                                 $word .= 'ի';
00063                                         break;
00064                                 case 'dative':  # Տրական հոլով
00065                                         # stub
00066                                         break;
00067                                 case 'accusative': # Հայցական հոլով
00068                                         # stub
00069                                         break;
00070                                 case 'instrumental':  #
00071                                         # stub
00072                                         break;
00073                                 case 'prepositional': #
00074                                         # stub
00075                                         break;
00076                         }
00077                 return $word;
00078         }
00079 
00086         function convertPlural( $count, $forms ) {
00087                 if ( !count( $forms ) ) { return ''; }
00088                 $forms = $this->preConvertPlural( $forms, 2 );
00089 
00090                 return ( abs( $count ) <= 1 ) ? $forms[0] : $forms[1];
00091         }
00092 
00100         function commafy( $_ ) {
00101                 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
00102                         return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
00103                 } else {
00104                         return $_;
00105                 }
00106         }
00107 }