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