2004-02-18 02:15:00 +00:00
|
|
|
|
<?php
|
2012-06-08 20:42:57 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Russian (русский язык) specific code.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
*
|
|
|
|
|
|
* @file
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
|
2012-06-08 20:42:57 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Russian (русский язык)
|
|
|
|
|
|
*
|
|
|
|
|
|
* You can contact Alexander Sigachov (alexander.sigachov at Googgle Mail)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2006-07-26 07:15:39 +00:00
|
|
|
|
class LanguageRu extends Language {
|
2011-05-29 16:32:05 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Convert from the nominative form of a noun to some other case
|
|
|
|
|
|
* Invoked with {{grammar:case|word}}
|
|
|
|
|
|
*
|
2014-04-17 13:31:28 +00:00
|
|
|
|
* @param string $word
|
|
|
|
|
|
* @param string $case
|
2011-05-29 16:32:05 +00:00
|
|
|
|
* @return string
|
|
|
|
|
|
*/
|
2005-08-15 19:27:58 +00:00
|
|
|
|
function convertGrammar( $word, $case ) {
|
2006-05-25 14:31:28 +00:00
|
|
|
|
global $wgGrammarForms;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( isset( $wgGrammarForms['ru'][$case][$word] ) ) {
|
2006-05-25 20:52:45 +00:00
|
|
|
|
return $wgGrammarForms['ru'][$case][$word];
|
2006-05-25 14:31:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-01-03 08:16:19 +00:00
|
|
|
|
# These rules are not perfect, but they are currently only used for Wikimedia
|
|
|
|
|
|
# site names so it doesn't matter if they are wrong sometimes.
|
|
|
|
|
|
# Just add a special case for your site name if necessary.
|
2005-08-15 19:27:58 +00:00
|
|
|
|
|
2013-02-11 05:09:41 +00:00
|
|
|
|
# substr doesn't support Unicode and mb_substr has issues,
|
|
|
|
|
|
# so break it to characters using preg_match_all and then use array_slice and join
|
|
|
|
|
|
$chars = array();
|
|
|
|
|
|
preg_match_all( '/./us', $word, $chars );
|
|
|
|
|
|
if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
|
2005-08-15 19:27:58 +00:00
|
|
|
|
switch ( $case ) {
|
2010-07-29 09:43:18 +00:00
|
|
|
|
case 'genitive': # родительный падеж
|
2013-02-11 05:09:41 +00:00
|
|
|
|
if ( join( '', array_slice( $chars[0], -1 ) ) === 'ь' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -1 ) ) . 'я';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ия' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ии';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ка' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ки';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ти' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'тей';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ды' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'дов';
|
2014-06-08 18:55:16 +00:00
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -1 ) ) === 'д' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -1 ) ) . 'да';
|
2013-02-11 05:09:41 +00:00
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ник' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'ника';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ные' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'ных';
|
|
|
|
|
|
}
|
2005-08-15 19:27:58 +00:00
|
|
|
|
break;
|
2013-02-11 05:09:41 +00:00
|
|
|
|
case 'dative': # дательный падеж
|
2010-07-29 09:43:18 +00:00
|
|
|
|
# stub
|
2005-08-15 19:27:58 +00:00
|
|
|
|
break;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
case 'accusative': # винительный падеж
|
|
|
|
|
|
# stub
|
2005-08-15 19:27:58 +00:00
|
|
|
|
break;
|
2013-02-11 05:09:41 +00:00
|
|
|
|
case 'instrumental': # творительный падеж
|
2010-07-29 09:43:18 +00:00
|
|
|
|
# stub
|
2005-08-15 19:27:58 +00:00
|
|
|
|
break;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
case 'prepositional': # предложный падеж
|
2013-02-11 05:09:41 +00:00
|
|
|
|
if ( join( '', array_slice( $chars[0], -1 ) ) === 'ь' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -1 ) ) . 'е';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ия' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ии';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ка' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'ке';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ти' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'тях';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -2 ) ) === 'ды' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -2 ) ) . 'дах';
|
2014-06-08 18:55:16 +00:00
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -1 ) ) === 'д' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -1 ) ) . 'де';
|
2013-02-11 05:09:41 +00:00
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ник' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'нике';
|
|
|
|
|
|
} elseif ( join( '', array_slice( $chars[0], -3 ) ) === 'ные' ) {
|
|
|
|
|
|
$word = join( '', array_slice( $chars[0], 0, -3 ) ) . 'ных';
|
|
|
|
|
|
}
|
2005-08-15 19:27:58 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2013-02-11 05:09:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-15 19:27:58 +00:00
|
|
|
|
return $word;
|
|
|
|
|
|
}
|
2005-04-05 21:03:33 +00:00
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2008-09-14 09:06:14 +00:00
|
|
|
|
* Four-digit number should be without group commas (spaces)
|
|
|
|
|
|
* See manual of style at http://ru.wikipedia.org/wiki/Википедия:Оформление_статей
|
|
|
|
|
|
* So "1 234 567", "12 345" but "1234"
|
2011-05-29 15:59:47 +00:00
|
|
|
|
*
|
2014-04-17 13:31:28 +00:00
|
|
|
|
* @param string $_
|
2011-05-29 15:59:47 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @return string
|
2006-01-05 23:51:02 +00:00
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function commafy( $_ ) {
|
|
|
|
|
|
if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
|
2006-04-29 20:07:14 +00:00
|
|
|
|
return $_;
|
2008-09-14 09:06:14 +00:00
|
|
|
|
} else {
|
2010-07-29 09:43:18 +00:00
|
|
|
|
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
|
2006-04-29 20:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
}
|