Stylize languages/*, languages/classes/*, but not languages/messages/*
[lhc/web/wiklou.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 /**
13 * Convert grammar forms of words.
14 *
15 * Available cases:
16 * "prefixed" (or "תחילית") - when the word has a prefix
17 *
18 * @param $word String: the word to convert
19 * @param $case String: the case
20 */
21 public function convertGrammar( $word, $case ) {
22 global $wgGrammarForms;
23 if ( isset( $wgGrammarForms['he'][$case][$word] ) ) {
24 return $wgGrammarForms['he'][$case][$word];
25 }
26
27 switch ( $case ) {
28 case 'prefixed':
29 case 'תחילית':
30 # Duplicate the "Waw" if prefixed
31 if ( substr( $word, 0, 2 ) == "ו" && substr( $word, 0, 4 ) != "וו" ) {
32 $word = "ו" . $word;
33 }
34
35 # Remove the "He" if prefixed
36 if ( substr( $word, 0, 2 ) == "ה" ) {
37 $word = substr( $word, 2 );
38 }
39
40 # Add a hyphen if non-Hebrew letters
41 if ( substr( $word, 0, 2 ) < "א" || substr( $word, 0, 2 ) > "ת" ) {
42 $word = "־" . $word;
43 }
44 }
45
46 return $word;
47 }
48
49 /**
50 * Gets a number and uses the suited form of the word.
51 *
52 * @param $count Integer: the number of items
53 * @param $forms Array with 3 items: the three plural forms
54 * @return String: the suited form of word
55 */
56 function convertPlural( $count, $forms ) {
57 if ( !count( $forms ) ) { return ''; }
58 $forms = $this->preConvertPlural( $forms, 3 );
59
60 if ( $count == '1' ) {
61 return $forms[0];
62 } elseif ( $count == '2' && isset( $forms[2] ) ) {
63 return $forms[2];
64 } else {
65 return $forms[1];
66 }
67 }
68 }