Braces, spaces, and a few unused arrays
[lhc/web/wiklou.git] / languages / classes / LanguageHy.php
1 <?php
2
3 /** Armenian (Հայերեն)
4 *
5 * @ingroup Language
6 * @author Ruben Vardanyan (Me@RubenVardanyan.com)
7 */
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];
15 }
16
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.
19
20 # join and array_slice instead mb_substr
21 $ar = array();
22 preg_match_all( '/./us', $word, $ar );
23 if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
24 switch ( $case ) {
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 ) ) . 'գրքի';
32 else
33 $word .= 'ի';
34 break;
35 case 'dative': # Տրական հոլով
36 # stub
37 break;
38 case 'accusative': # Հայցական հոլով
39 # stub
40 break;
41 case 'instrumental': #
42 # stub
43 break;
44 case 'prepositional': #
45 # stub
46 break;
47 }
48 return $word;
49 }
50
51 function convertPlural( $count, $forms ) {
52 if ( !count( $forms ) ) { return ''; }
53 $forms = $this->preConvertPlural( $forms, 2 );
54
55 return ( abs( $count ) <= 1 ) ? $forms[0] : $forms[1];
56 }
57
58 /*
59 * Armenian numeric format is "12 345,67" but "1234,56"
60 */
61
62 function commafy( $_ ) {
63 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
64 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
65 } else {
66 return $_;
67 }
68 }
69 }