]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - languages/classes/LanguageHe.php
MediaWiki 1.14.0-scripts
[autoinstalls/mediawiki.git] / languages / classes / LanguageHe.php
1 <?php
2
3 /**
4  * Hebrew (עברית)
5  *
6  * @ingroup Language
7  *
8  * @author Rotem Liss
9  */
10 class LanguageHe extends Language {
11         /**
12          * Convert grammar forms of words.
13          *
14          * Available cases:
15          * "prefixed" (or "תחילית") - when the word has a prefix
16          *
17          * @param string the word to convert
18          * @param string the case
19          */
20         public function convertGrammar( $word, $case ) {
21                 global $wgGrammarForms;
22                 if ( isset($wgGrammarForms['he'][$case][$word]) ) {
23                         return $wgGrammarForms['he'][$case][$word];
24                 }
25                 
26                 switch ( $case ) {
27                         case 'prefixed':
28                         case 'תחילית':
29                                 # Duplicate the "Waw" if prefixed
30                                 if ( substr( $word, 0, 2 ) == "ו" && substr( $word, 0, 4 ) != "וו" ) {
31                                         $word = "ו".$word;
32                                 }
33                                 
34                                 # Remove the "He" if prefixed
35                                 if ( substr( $word, 0, 2 ) == "ה" ) {
36                                         $word = substr( $word, 2 );
37                                 }
38                                 
39                                 # Add a hyphen if non-Hebrew letters
40                                 if ( substr( $word, 0, 2 ) < "א" || substr( $word, 0, 2 ) > "ת" ) {
41                                         $word = "־".$word;
42                                 }
43                 }
44                 
45                 return $word;
46         }
47         
48         /**
49          * Gets a number and uses the suited form of the word.
50          *
51          * @param integer the number of items
52          * @param string the first form (singular)
53          * @param string the second form (plural)
54          * @param string the third form (2 items, plural is used if not applicable and not specified
55          * @param not used (for compatibility with ancestor)
56          * @param not used (for compatibility with ancestor)
57          *
58          * @return string of the suited form of word
59          */
60         function convertPlural( $count, $forms ) {
61                 if ( !count($forms) ) { return ''; }
62                 $forms = $this->preConvertPlural( $forms, 3 );
63
64                 if ( $count == '1' ) {
65                         return $forms[0];
66                 } elseif ( $count == '2' && isset($forms[2]) ) {
67                         return $forms[2];
68                 } else {
69                         return $forms[1];
70                 }
71         }
72 }