ccc68f1e47cf8b358e3c6fe2816aac555aa567c6
[lhc/web/wiklou.git] / resources / src / 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 /*global $ */
11 'use strict';
12
13 var grammarForms = mediaWiki.language.getData( 'ru', 'grammarForms' );
14 if ( grammarForms && grammarForms[ form ] ) {
15 return grammarForms[ form ][ word ];
16 }
17 switch ( form ) {
18 case 'genitive': // родительный падеж
19 if ( word.slice( -1 ) === 'ь' ) {
20 word = word.slice( 0, -1 ) + 'я';
21 } else if ( word.slice( -2 ) === 'ия' ) {
22 word = word.slice( 0, -2 ) + 'ии';
23 } else if ( word.slice( -2 ) === 'ка' ) {
24 word = word.slice( 0, -2 ) + 'ки';
25 } else if ( word.slice( -2 ) === 'ти' ) {
26 word = word.slice( 0, -2 ) + 'тей';
27 } else if ( word.slice( -2 ) === 'ды' ) {
28 word = word.slice( 0, -2 ) + 'дов';
29 } else if ( word.slice( -1 ) === 'д' ) {
30 word = word.slice( 0, -1 ) + 'да';
31 } else if ( word.slice( -3 ) === 'ные' ) {
32 word = word.slice( 0, -3 ) + 'ных';
33 } else if ( word.slice( -3 ) === 'ник' ) {
34 word = word.slice( 0, -3 ) + 'ника';
35 }
36 break;
37 case 'prepositional': // предложный падеж
38 if ( word.slice( -1 ) === 'ь' ) {
39 word = word.slice( 0, -1 ) + 'е';
40 } else if ( word.slice( -2 ) === 'ия' ) {
41 word = word.slice( 0, -2 ) + 'ии';
42 } else if ( word.slice( -2 ) === 'ка' ) {
43 word = word.slice( 0, -2 ) + 'ке';
44 } else if ( word.slice( -2 ) === 'ти' ) {
45 word = word.slice( 0, -2 ) + 'тях';
46 } else if ( word.slice( -2 ) === 'ды' ) {
47 word = word.slice( 0, -2 ) + 'дах';
48 } else if ( word.slice( -1 ) === 'д' ) {
49 word = word.slice( 0, -1 ) + 'де';
50 } else if ( word.slice( -3 ) === 'ные' ) {
51 word = word.slice( 0, -3 ) + 'ных';
52 } else if ( word.slice( -3 ) === 'ник' ) {
53 word = word.slice( 0, -3 ) + 'нике';
54 }
55 break;
56 case 'languagegen': // язык в родительном падеже ("(с) русского")
57 if ( word.slice( -3 ) === 'кий' ) {
58 word = word.slice( 0, -2 ) + 'ого';
59 } else if ( $.inArray( word, [ 'иврит', 'идиш' ] ) > -1 ) {
60 word = word + 'а';
61 }
62 break;
63 case 'languageprep': // язык в предложном падеже ("(на) русском")
64 if ( word.slice( -3 ) === 'кий' ) {
65 word = word.slice( 0, -2 ) + 'ом';
66 } else if ( $.inArray( word, [ 'иврит', 'идиш' ] ) > -1 ) {
67 word = word + 'е';
68 }
69 break;
70 case 'languageadverb': // наречие с названием языка ("по-русски")
71 if ( word.slice( -3 ) === 'кий' ) {
72 word = 'по-' + word.slice( 0, -1 );
73 } else if ( $.inArray( word, [ 'иврит', 'идиш' ] ) > -1 ) {
74 word = 'на ' + word + 'е';
75 } else if ( $.inArray( word, [ 'идо', 'урду', 'хинди', 'эсперанто' ] ) > -1 ) {
76 word = 'на ' + word;
77 } else {
78 word = 'на языке ' + word;
79 }
80 break;
81 }
82 return word;
83 };