MediaWiki  master
LanguageHy.php
Go to the documentation of this file.
1 <?php
24 
30 class LanguageHy extends Language {
31 
40  public function convertGrammar( $word, $case ) {
41  $grammarForms =
42  MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
43  if ( isset( $grammarForms['hy'][$case][$word] ) ) {
44  return $grammarForms['hy'][$case][$word];
45  }
46 
47  # These rules are not perfect, but they are currently only used for site names so it doesn't
48  # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
49 
50  # join and array_slice instead mb_substr
51  $ar = [];
52  preg_match_all( '/./us', $word, $ar );
53  if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
54  switch ( $case ) {
55  case 'genitive': # սեռական հոլով
56  if ( implode( '', array_slice( $ar[0], -1 ) ) == 'ա' ) {
57  $word = implode( '', array_slice( $ar[0], 0, -1 ) ) . 'այի';
58  } elseif ( implode( '', array_slice( $ar[0], -1 ) ) == 'ո' ) {
59  $word = implode( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի';
60  } elseif ( implode( '', array_slice( $ar[0], -4 ) ) == 'գիրք' ) {
61  $word = implode( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի';
62  } else {
63  $word .= 'ի';
64  }
65  break;
66  case 'dative': # Տրական հոլով
67  # stub
68  break;
69  case 'accusative': # Հայցական հոլով
70  # stub
71  break;
72  case 'instrumental':
73  # stub
74  break;
75  case 'prepositional':
76  # stub
77  break;
78  }
79  }
80  return $word;
81  }
82 }
Armenian (Հայերեն)
Definition: LanguageHy.php:30
convertGrammar( $word, $case)
Convert from the nominative form of a noun to some other case Invoked with {{grammar:case|word}}.
Definition: LanguageHy.php:40
Base class for language-specific code.
Definition: Language.php:54
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.