MediaWiki  1.23.13
LanguageRu.php
Go to the documentation of this file.
1 <?php
31 class LanguageRu extends Language {
32 
41  function convertGrammar( $word, $case ) {
42  global $wgGrammarForms;
43  if ( isset( $wgGrammarForms['ru'][$case][$word] ) ) {
44  return $wgGrammarForms['ru'][$case][$word];
45  }
46 
47  # These rules are not perfect, but they are currently only used for Wikimedia
48  # site names so it doesn't matter if they are wrong sometimes.
49  # Just add a special case for your site name if necessary.
50 
51  # substr doesn't support Unicode and mb_substr has issues,
52  # so break it to characters using preg_match_all and then use array_slice and join
53  $chars = array();
54  preg_match_all( '/./us', $word, $chars );
55  if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
56  switch ( $case ) {
57  case 'genitive': # родительный падеж
58  if ( join( '', array_slice( $chars[0], -1 ) ) === 'ь' ) {
59  $word = join( '', array_slice( $chars[0], 0, -1 ) ) . 'я';
60  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ия' ) {
61  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ии';
62  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ка' ) {
63  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ки';
64  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ти' ) {
65  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'тей';
66  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ды' ) {
67  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'дов';
68  } elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ник' ) {
69  $word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'ника';
70  } elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ные' ) {
71  $word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'ных';
72  }
73  break;
74  case 'dative': # дательный падеж
75  # stub
76  break;
77  case 'accusative': # винительный падеж
78  # stub
79  break;
80  case 'instrumental': # творительный падеж
81  # stub
82  break;
83  case 'prepositional': # предложный падеж
84  if ( join( '', array_slice( $chars[0], -1 ) ) === 'ь' ) {
85  $word = join( '', array_slice( $chars[0], 0, -1 ) ) . 'е';
86  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ия' ) {
87  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ии';
88  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ка' ) {
89  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ке';
90  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ти' ) {
91  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'тях';
92  } elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ды' ) {
93  $word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'дах';
94  } elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ник' ) {
95  $word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'нике';
96  } elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ные' ) {
97  $word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'ных';
98  }
99  break;
100  }
101  }
102 
103  return $word;
104  }
105 
115  function commafy( $_ ) {
116  if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
117  return $_;
118  } else {
119  return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
120  }
121  }
122 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
LanguageRu\convertGrammar
convertGrammar( $word, $case)
Convert from the nominative form of a noun to some other case Invoked with {{grammar:case|word}}.
Definition: LanguageRu.php:41
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
LanguageRu
Russian (русский язык)
Definition: LanguageRu.php:31
LanguageRu\commafy
commafy( $_)
Four-digit number should be without group commas (spaces) See manual of style at http://ru....
Definition: LanguageRu.php:115
Language
Internationalisation code.
Definition: Language.php:74