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