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