a251aa529a32f63fa652f91c82095b72da026939
[lhc/web/wiklou.git] / languages / classes / LanguageRu.php
1 <?php
2 /** Russian (русский язык)
3 *
4 * You can contact Alexander Sigachov (alexander.sigachov at Googgle Mail)
5 *
6 * @package MediaWiki
7 * @subpackage Language
8 */
9
10 /* Please, see Language.php for general function comments */
11 class LanguageRu extends Language {
12 # Convert from the nominative form of a noun to some other case
13 # Invoked with {{grammar:case|word}}
14 function convertGrammar( $word, $case ) {
15 global $wgGrammarForms;
16 if ( isset($wgGrammarForms['ru'][$case][$word]) ) {
17 return $wgGrammarForms['ru'][$case][$word];
18 }
19
20 # These rules are not perfect, but they are currently only used for site names so it doesn't
21 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
22
23 #join and array_slice instead mb_substr
24 $ar = array();
25 preg_match_all( '/./us', $word, $ar );
26 if (!preg_match("/[a-zA-Z_]/us", $word))
27 switch ( $case ) {
28 case 'genitive': #родительный падеж
29 if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики'))
30 {}
31 elseif (join('',array_slice($ar[0],-1))=='ь')
32 $word = join('',array_slice($ar[0],0,-1)).'я';
33 elseif (join('',array_slice($ar[0],-2))=='ия')
34 $word=join('',array_slice($ar[0],0,-2)).'ии';
35 elseif (join('',array_slice($ar[0],-2))=='ка')
36 $word=join('',array_slice($ar[0],0,-2)).'ки';
37 elseif (join('',array_slice($ar[0],-2))=='ти')
38 $word=join('',array_slice($ar[0],0,-2)).'тей';
39 elseif (join('',array_slice($ar[0],-2))=='ды')
40 $word=join('',array_slice($ar[0],0,-2)).'дов';
41 elseif (join('',array_slice($ar[0],-3))=='ник')
42 $word=join('',array_slice($ar[0],0,-3)).'ника';
43 break;
44 case 'dative': #дательный падеж
45 #stub
46 break;
47 case 'accusative': #винительный падеж
48 #stub
49 break;
50 case 'instrumental': #творительный падеж
51 #stub
52 break;
53 case 'prepositional': #предложный падеж
54 #stub
55 break;
56 }
57 return $word;
58 }
59
60 function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
61 $count = str_replace (' ', '', $count);
62 if ($count > 10 && floor(($count % 100) / 10) == 1) {
63 return $wordform3;
64 } else {
65 switch ($count % 10) {
66 case 1: return $wordform1;
67 case 2:
68 case 3:
69 case 4: return $wordform2;
70 default: return $wordform3;
71 }
72 }
73 }
74
75 /*
76 * Russian numeric format is "12 345,67" but "1234,56"
77 */
78
79 function commafy($_) {
80 if (!preg_match('/^\d{1,4}$/',$_)) {
81 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
82 } else {
83 return $_;
84 }
85 }
86 }
87 ?>