* Reworked convertPlural so that it accepts variable number of arguments nicely
[lhc/web/wiklou.git] / languages / classes / LanguageHe.php
1 <?php
2 /**
3 * Hebrew (עברית)
4 *
5 * @addtogroup Language
6 *
7 * @author Rotem Liss
8 */
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' && $w3 ) {
67 return $forms[2];
68 } else {
69 return $forms[1];
70 }
71 }
72 }
73
74