LanguageHe.php 1.7 KB

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