JSDuck-ify /resources/mediawiki.language/*
[lhc/web/wiklou.git] / resources / mediawiki.language / languages / ru.js
1 /*!
2 * Russian (Русский) language functions
3 */
4
5 // These tests were originally made for names of Wikimedia
6 // websites, so they don't currently cover all the possible
7 // cases.
8
9 mediaWiki.language.convertGrammar = function ( word, form ) {
10 'use strict';
11
12 var grammarForms = mediaWiki.language.getData( 'ru', 'grammarForms' );
13 if ( grammarForms && grammarForms[form] ) {
14 return grammarForms[form][word];
15 }
16 switch ( form ) {
17 case 'genitive': // родительный падеж
18 if ( word.substr( word.length - 1 ) === 'ь' ) {
19 word = word.substr(0, word.length - 1 ) + 'я';
20 } else if ( word.substr( word.length - 2 ) === 'ия' ) {
21 word = word.substr(0, word.length - 2 ) + 'ии';
22 } else if ( word.substr( word.length - 2 ) === 'ка' ) {
23 word = word.substr(0, word.length - 2 ) + 'ки';
24 } else if ( word.substr( word.length - 2 ) === 'ти' ) {
25 word = word.substr(0, word.length - 2 ) + 'тей';
26 } else if ( word.substr( word.length - 2 ) === 'ды' ) {
27 word = word.substr(0, word.length - 2 ) + 'дов';
28 } else if ( word.substr( word.length - 3 ) === 'ные' ) {
29 word = word.substr(0, word.length - 3 ) + 'ных';
30 } else if ( word.substr( word.length - 3 ) === 'ник' ) {
31 word = word.substr(0, word.length - 3 ) + 'ника';
32 }
33 break;
34 case 'prepositional': // предложный падеж
35 if ( word.substr( word.length - 1 ) === 'ь' ) {
36 word = word.substr(0, word.length - 1 ) + 'е';
37 } else if ( word.substr( word.length - 2 ) === 'ия' ) {
38 word = word.substr(0, word.length - 2 ) + 'ии';
39 } else if ( word.substr( word.length - 2 ) === 'ка' ) {
40 word = word.substr(0, word.length - 2 ) + 'ке';
41 } else if ( word.substr( word.length - 2 ) === 'ти' ) {
42 word = word.substr(0, word.length - 2 ) + 'тях';
43 } else if ( word.substr( word.length - 2 ) === 'ды' ) {
44 word = word.substr(0, word.length - 2 ) + 'дах';
45 } else if ( word.substr( word.length - 3 ) === 'ные' ) {
46 word = word.substr(0, word.length - 3 ) + 'ных';
47 } else if ( word.substr( word.length - 3 ) === 'ник' ) {
48 word = word.substr(0, word.length - 3 ) + 'нике';
49 }
50 break;
51 }
52 return word;
53 };