2004-02-18 02:15:00 +00:00
|
|
|
|
<?php
|
2005-04-27 21:10:42 +00:00
|
|
|
|
/** Russian (русский язык)
|
|
|
|
|
|
*
|
2006-01-29 14:43:42 +00:00
|
|
|
|
* You can contact Alexander Sigachov (alexander.sigachov at Googgle Mail)
|
2005-04-27 21:10:42 +00:00
|
|
|
|
*
|
2007-01-20 15:09:52 +00:00
|
|
|
|
* @addtogroup Language
|
2005-04-05 11:00:27 +00:00
|
|
|
|
*/
|
2003-11-09 11:24:43 +00:00
|
|
|
|
|
2005-05-31 21:55:56 +00:00
|
|
|
|
/* Please, see Language.php for general function comments */
|
2006-07-26 07:15:39 +00:00
|
|
|
|
class LanguageRu extends Language {
|
2005-08-15 19:27:58 +00:00
|
|
|
|
# Convert from the nominative form of a noun to some other case
|
|
|
|
|
|
# Invoked with {{grammar:case|word}}
|
|
|
|
|
|
function convertGrammar( $word, $case ) {
|
2006-05-25 14:31:28 +00:00
|
|
|
|
global $wgGrammarForms;
|
2006-05-25 20:52:45 +00:00
|
|
|
|
if ( isset($wgGrammarForms['ru'][$case][$word]) ) {
|
|
|
|
|
|
return $wgGrammarForms['ru'][$case][$word];
|
2006-05-25 14:31:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-15 19:27:58 +00:00
|
|
|
|
# These rules are not perfect, but they are currently only used for site names so it doesn't
|
|
|
|
|
|
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
|
|
|
|
|
|
|
|
|
|
|
|
#join and array_slice instead mb_substr
|
2006-05-01 11:03:02 +00:00
|
|
|
|
$ar = array();
|
2005-08-15 19:27:58 +00:00
|
|
|
|
preg_match_all( '/./us', $word, $ar );
|
|
|
|
|
|
if (!preg_match("/[a-zA-Z_]/us", $word))
|
|
|
|
|
|
switch ( $case ) {
|
|
|
|
|
|
case 'genitive': #родительный падеж
|
|
|
|
|
|
if ((join('',array_slice($ar[0],-4))=='вики') || (join('',array_slice($ar[0],-4))=='Вики'))
|
|
|
|
|
|
{}
|
|
|
|
|
|
elseif (join('',array_slice($ar[0],-1))=='ь')
|
|
|
|
|
|
$word = join('',array_slice($ar[0],0,-1)).'я';
|
|
|
|
|
|
elseif (join('',array_slice($ar[0],-2))=='ия')
|
|
|
|
|
|
$word=join('',array_slice($ar[0],0,-2)).'ии';
|
2005-09-18 08:19:06 +00:00
|
|
|
|
elseif (join('',array_slice($ar[0],-2))=='ка')
|
|
|
|
|
|
$word=join('',array_slice($ar[0],0,-2)).'ки';
|
2005-08-15 19:27:58 +00:00
|
|
|
|
elseif (join('',array_slice($ar[0],-2))=='ти')
|
|
|
|
|
|
$word=join('',array_slice($ar[0],0,-2)).'тей';
|
|
|
|
|
|
elseif (join('',array_slice($ar[0],-2))=='ды')
|
|
|
|
|
|
$word=join('',array_slice($ar[0],0,-2)).'дов';
|
|
|
|
|
|
elseif (join('',array_slice($ar[0],-3))=='ник')
|
|
|
|
|
|
$word=join('',array_slice($ar[0],0,-3)).'ника';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'dative': #дательный падеж
|
|
|
|
|
|
#stub
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'accusative': #винительный падеж
|
|
|
|
|
|
#stub
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'instrumental': #творительный падеж
|
|
|
|
|
|
#stub
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'prepositional': #предложный падеж
|
|
|
|
|
|
#stub
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
return $word;
|
|
|
|
|
|
}
|
2005-04-05 21:03:33 +00:00
|
|
|
|
|
2006-12-16 22:31:08 +00:00
|
|
|
|
function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
|
2006-01-29 14:43:42 +00:00
|
|
|
|
$count = str_replace (' ', '', $count);
|
2005-09-05 19:22:09 +00:00
|
|
|
|
if ($count > 10 && floor(($count % 100) / 10) == 1) {
|
|
|
|
|
|
return $wordform3;
|
2006-01-03 15:53:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
switch ($count % 10) {
|
|
|
|
|
|
case 1: return $wordform1;
|
2006-05-26 20:33:38 +00:00
|
|
|
|
case 2:
|
|
|
|
|
|
case 3:
|
2006-01-03 15:53:44 +00:00
|
|
|
|
case 4: return $wordform2;
|
2005-09-05 19:22:09 +00:00
|
|
|
|
default: return $wordform3;
|
2006-01-03 15:53:44 +00:00
|
|
|
|
}
|
2005-09-05 19:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-04-29 20:07:14 +00:00
|
|
|
|
/*
|
2006-01-26 21:27:31 +00:00
|
|
|
|
* Russian numeric format is "12 345,67" but "1234,56"
|
2006-01-05 23:51:02 +00:00
|
|
|
|
*/
|
2006-01-26 21:27:31 +00:00
|
|
|
|
|
2006-04-29 20:07:14 +00:00
|
|
|
|
function commafy($_) {
|
|
|
|
|
|
if (!preg_match('/^\d{1,4}$/',$_)) {
|
|
|
|
|
|
return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return $_;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
}
|
2007-06-29 01:19:14 +00:00
|
|
|
|
|