]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - languages/classes/LanguageHy.php
MediaWiki 1.11.0-scripts
[autoinstallsdev/mediawiki.git] / languages / classes / LanguageHy.php
1 <?php
2 /** Armenian (Հայերեն)
3   *
4   * @addtogroup Language
5   * @author Ruben Vardanyan (Me@RubenVardanyan.com)
6   */
7
8 /* Please, see Language.php for general function comments */
9 class LanguageHy extends Language {
10         # Convert from the nominative form of a noun to some other case
11         # Invoked with {{grammar:case|word}}
12         function convertGrammar( $word, $case ) {
13                 global $wgGrammarForms;
14                 if ( isset($wgGrammarForms['hy'][$case][$word]) ) {
15                         return $wgGrammarForms['hy'][$case][$word];
16                 }
17
18                 # These rules are not perfect, but they are currently only used for site names so it doesn't
19                 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
20
21                 #join and array_slice instead mb_substr
22                 $ar = array();
23                 preg_match_all( '/./us', $word, $ar );
24                 if (!preg_match("/[a-zA-Z_]/us", $word))
25                         switch ( $case ) {
26                                 case 'genitive': #սեռական հոլով
27                                         if (join('',array_slice($ar[0],-1))=='ա')
28                                                 $word = join('',array_slice($ar[0],0,-1)).'այի';
29                                         elseif (join('',array_slice($ar[0],-1))=='ո')
30                                                 $word=join('',array_slice($ar[0],0,-1)).'ոյի';
31                                         elseif (join('',array_slice($ar[0],-4))=='գիրք')
32                                                 $word=join('',array_slice($ar[0],0,-4)).'գրքի';
33                                         else
34                                                 $word.='ի';
35                                         break;
36                                 case 'dative':  #Տրական հոլով
37                                         #stub
38                                         break;
39                                 case 'accusative': #Հայցական հոլով
40                                         #stub
41                                         break;
42                                 case 'instrumental':  #
43                                         #stub
44                                         break;
45                                 case 'prepositional': #
46                                         #stub
47                                         break;
48                         }
49                 return $word;
50         }
51
52         function convertPlural( $count, $wordform1, $wordform2) {
53                 $count = str_replace (' ', '', $count);
54                 if (abs($count) <= 1) {
55                         return $wordform1;
56                 } else {
57                         return $wordform2;
58                 }
59         }
60
61         /*
62          * Armenian numeric format is "12 345,67" but "1234,56"
63          */
64
65         function commafy($_) {
66                 if (!preg_match('/^\d{1,4}$/',$_)) {
67                         return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
68                 } else {
69                         return $_;
70                 }
71         }
72 }
73