MediaWiki
REL1_19
|
00001 <?php 00002 00008 class LanguageHy extends Language { 00009 00018 function convertGrammar( $word, $case ) { 00019 global $wgGrammarForms; 00020 if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) { 00021 return $wgGrammarForms['hy'][$case][$word]; 00022 } 00023 00024 # These rules are not perfect, but they are currently only used for site names so it doesn't 00025 # matter if they are wrong sometimes. Just add a special case for your site name if necessary. 00026 00027 # join and array_slice instead mb_substr 00028 $ar = array(); 00029 preg_match_all( '/./us', $word, $ar ); 00030 if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) 00031 switch ( $case ) { 00032 case 'genitive': # սեռական հոլով 00033 if ( join( '', array_slice( $ar[0], -1 ) ) == 'ա' ) 00034 $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'այի'; 00035 elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ո' ) 00036 $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի'; 00037 elseif ( join( '', array_slice( $ar[0], -4 ) ) == 'գիրք' ) 00038 $word = join( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի'; 00039 else 00040 $word .= 'ի'; 00041 break; 00042 case 'dative': # Տրական հոլով 00043 # stub 00044 break; 00045 case 'accusative': # Հայցական հոլով 00046 # stub 00047 break; 00048 case 'instrumental': # 00049 # stub 00050 break; 00051 case 'prepositional': # 00052 # stub 00053 break; 00054 } 00055 return $word; 00056 } 00057 00064 function convertPlural( $count, $forms ) { 00065 if ( !count( $forms ) ) { return ''; } 00066 $forms = $this->preConvertPlural( $forms, 2 ); 00067 00068 return ( abs( $count ) <= 1 ) ? $forms[0] : $forms[1]; 00069 } 00070 00078 function commafy( $_ ) { 00079 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) { 00080 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); 00081 } else { 00082 return $_; 00083 } 00084 } 00085 }