MediaWiki  master
LanguageCu.php
Go to the documentation of this file.
1 <?php
23 
29 class LanguageCu extends Language {
38  public function convertGrammar( $word, $case ) {
39  $grammarForms =
40  MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
41 
42  if ( isset( $grammarForms['сu'][$case][$word] ) ) {
43  return $grammarForms['сu'][$case][$word];
44  }
45 
46  # These rules are not perfect, but they are currently only used for
47  # site names so it doesn't matter if they are wrong sometimes. Just add
48  # 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], -4 ) ) == 'вики' )
57  || ( implode( '', array_slice( $ar[0], -4 ) ) == 'Вики' )
58  ) {
59  } elseif ( implode( '', array_slice( $ar[0], -2 ) ) == 'ї' ) {
60  $word = implode( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ';
61  }
62  break;
63  case 'accusative': # винительный падеж
64  # stub
65  break;
66  }
67  }
68 
69  return $word;
70  }
71 }
Old Church Slavonic (Ѩзыкъ словѣньскъ)
Definition: LanguageCu.php:29
convertGrammar( $word, $case)
Convert from the nominative form of a noun to some other case Invoked with {{grammar:case|word}}.
Definition: LanguageCu.php:38
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.