MediaWiki  REL1_22
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                     }
00064                     break;
00065                 case 'dative':  # Տրական հոլով
00066                     # stub
00067                     break;
00068                 case 'accusative': # Հայցական հոլով
00069                     # stub
00070                     break;
00071                 case 'instrumental':  #
00072                     # stub
00073                     break;
00074                 case 'prepositional': #
00075                     # stub
00076                     break;
00077             }
00078         }
00079         return $word;
00080     }
00081 
00089     function commafy( $_ ) {
00090         if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
00091             return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
00092         } else {
00093             return $_;
00094         }
00095     }
00096 }