Index: branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | test: [ |
99 | 99 | { word: 'Wikipédiá', grammarForm: 'rol', expected: 'Wikipédiáról', description: 'Grammar test for Hungarian, rol case' }, |
100 | 100 | { word: 'Wikipédiá', grammarForm: 'ba', expected: 'Wikipédiába', description: 'Grammar test for Hungarian, ba case' }, |
101 | | - { word: 'Wikipédiá', grammarForm: 'k', expected: 'Wikipédiák', description: 'Grammar test for Hungarian, k case' }, |
| 101 | + { word: 'Wikipédiá', grammarForm: 'k', expected: 'Wikipédiák', description: 'Grammar test for Hungarian, k case' } |
102 | 102 | ] |
103 | 103 | }); |
104 | 104 | |
— | — | @@ -106,6 +106,19 @@ |
107 | 107 | test: [ |
108 | 108 | { word: 'an Domhnach', grammarForm: 'ainmlae', expected: 'Dé Domhnaigh', description: 'Grammar test for Irish, ainmlae case' }, |
109 | 109 | { word: 'an Luan', grammarForm: 'ainmlae', expected: 'Dé Luain', description: 'Grammar test for Irish, ainmlae case' }, |
110 | | - { word: 'an Satharn', grammarForm: 'ainmlae', expected: 'Dé Sathairn', description: 'Grammar test for Irish, ainmlae case' }, |
| 110 | + { word: 'an Satharn', grammarForm: 'ainmlae', expected: 'Dé Sathairn', description: 'Grammar test for Irish, ainmlae case' } |
111 | 111 | ] |
112 | 112 | }); |
| 113 | + |
| 114 | +mw.language.grammartest({ |
| 115 | + language: 'uk', |
| 116 | + test: [ |
| 117 | + { word: 'тесть', grammarForm: 'genitive', expected: 'тестя', description: 'Grammar test for Ukrainian, genitive case' }, |
| 118 | + { word: 'Вікіпедія', grammarForm: 'genitive', expected: 'Вікіпедії', description: 'Grammar test for Ukrainian, genitive case' }, |
| 119 | + { word: 'установка', grammarForm: 'genitive', expected: 'установки', description: 'Grammar test for Ukrainian, genitive case' }, |
| 120 | + { word: 'похоти', grammarForm: 'genitive', expected: 'похотей', description: 'Grammar test for Ukrainian, genitive case' }, |
| 121 | + { word: 'доводы', grammarForm: 'genitive', expected: 'доводов', description: 'Grammar test for Ukrainian, genitive case' }, |
| 122 | + { word: 'песчаник', grammarForm: 'genitive', expected: 'песчаника', description: 'Grammar test for Ukrainian, genitive case' }, |
| 123 | + { word: 'Вікіпедія', grammarForm: 'accusative', expected: 'Вікіпедію', description: 'Grammar test for Ukrainian, accusative case' } |
| 124 | + ] |
| 125 | +}); |
Index: branches/jsgrammar/resources/mediawiki.language/languages/uk.js |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | /** |
3 | | - * Ukrainian (Українська) language functions |
| 3 | + * Ukrainian (УкÑаÑÐœÑÑка) language functions |
4 | 4 | */ |
5 | 5 | |
6 | 6 | mediaWiki.language.convertPlural = function( count, forms ) { |
— | — | @@ -21,3 +21,35 @@ |
22 | 22 | return forms[2]; |
23 | 23 | } |
24 | 24 | }; |
| 25 | + |
| 26 | +mediaWiki.language.convertGrammar = function( word, form ) { |
| 27 | + var grammarForms = mw.language.data[ 'uk' ].get( 'grammarForms' ); |
| 28 | + if ( grammarForms && grammarForms[form] ) { |
| 29 | + return grammarForms[form][word] ; |
| 30 | + } |
| 31 | + switch ( form ) { |
| 32 | + case 'genitive': // родовий відмінок |
| 33 | + if ( ( word.substr( word.length - 4 ) == 'вікі' ) || ( word.substr( word.length - 4 ) == 'Вікі' ) ) { |
| 34 | + } |
| 35 | + else 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 | + break; |
| 48 | + case 'accusative': // знахідний відмінок |
| 49 | + if ( ( word.substr( word.length - 4 ) == 'вікі' ) || ( word.substr( word.length - 4 ) == 'Вікі' ) ) { |
| 50 | + } |
| 51 | + else if ( word.substr( word.length - 2 ) == 'ія' ) |
| 52 | + word = word.substr(0, word.length - 2 ) + 'ію'; |
| 53 | + break; |
| 54 | + } |
| 55 | + return word; |
| 56 | +}; |