6 * @author Ruben Vardanyan (Me@RubenVardanyan.com)
8 class LanguageHy
extends Language
{
9 # Convert from the nominative form of a noun to some other case
10 # Invoked with {{grammar:case|word}}
11 function convertGrammar( $word, $case ) {
12 global $wgGrammarForms;
13 if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) {
14 return $wgGrammarForms['hy'][$case][$word];
17 # These rules are not perfect, but they are currently only used for site names so it doesn't
18 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
20 # join and array_slice instead mb_substr
22 preg_match_all( '/./us', $word, $ar );
23 if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
25 case 'genitive': # սեռական հոլով
26 if ( join( '', array_slice( $ar[0], -1 ) ) == 'ա' )
27 $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'այի';
28 elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ո' )
29 $word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի';
30 elseif ( join( '', array_slice( $ar[0], -4 ) ) == 'գիրք' )
31 $word = join( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի';
35 case 'dative': # Տրական հոլով
38 case 'accusative': # Հայցական հոլով
41 case 'instrumental': #
44 case 'prepositional': #
51 function convertPlural( $count, $forms ) {
52 if ( !count( $forms ) ) { return ''; }
53 $forms = $this->preConvertPlural( $forms, 2 );
55 return ( abs( $count ) <= 1 ) ?
$forms[0] : $forms[1];
59 * Armenian numeric format is "12 345,67" but "1234,56"
62 function commafy( $_ ) {
63 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
64 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );