LanguageHy.php 1.9 KB

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