wiki.techinc.nl/languages/classes/LanguageRu.php

87 lines
2.6 KiB
PHP
Raw Normal View History

<?php
/** Russian (русский язык)
*
2006-01-29 14:43:42 +00:00
* You can contact Alexander Sigachov (alexander.sigachov at Googgle Mail)
*
* @addtogroup Language
*/
2005-05-31 21:55:56 +00:00
/* Please, see Language.php for general function comments */
Merged localisation-work branch: * Made lines from initialiseMessages() appear as list items during installation * Moved the bulk of the localisation data from the Language*.php files to the Messages*.php files. Deleted most of the Languages*.php files. * Introduced "stub global" framework to provide deferred initialisation of core modules. * Removed placeholder values for $wgTitle and $wgArticle, these variables will now be null during the initialisation process, until they are set by index.php or another entry point. * Added DBA cache type, for BDB-style caches. * Removed custom date format functions, replacing them with a format string in the style of PHP's date(). Used string identifiers instead of integer identifiers, in both the language files and user preferences. Migration should be transparent in most cases. * Simplified the initialisation API for LoadBalancer objects. * Removed the broken altencoding feature. * Moved default user options and toggles from Language to User. Language objects are still able to define default preference overrides and extra user toggles, via a slightly different interface. * Don't include the date option in the parser cache rendering hash unless $wgUseDynamicDates is enabled. * Merged LanguageUtf8 with Language. Removed LanguageUtf8.php. * Removed inclusion of language files from the bottom of Language.php. This is now consistently done from Language::factory(). * Add the name of the executing maintenance script to the debug log. Start the profiler during maintenance scripts. * Added "serialized" directory, for storing precompiled data in serialized form.
2006-07-26 07:15:39 +00:00
class LanguageRu extends Language {
# Convert from the nominative form of a noun to some other case
# Invoked with {{grammar:case|word}}
function convertGrammar( $word, $case ) {
global $wgGrammarForms;
if ( isset($wgGrammarForms['ru'][$case][$word]) ) {
return $wgGrammarForms['ru'][$case][$word];
}
# 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();
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)).'ки';
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;
}
function convertPlural( $count, $wordform1, $wordform2, $wordform3, $w4, $w5) {
2006-01-29 14:43:42 +00:00
$count = str_replace (' ', '', $count);
if ($count > 10 && floor(($count % 100) / 10) == 1) {
return $wordform3;
} else {
switch ($count % 10) {
case 1: return $wordform1;
case 2:
case 3:
case 4: return $wordform2;
default: return $wordform3;
}
}
}
/*
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
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
}