Index: branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | // The test works only if the content language is opt.language |
16 | 16 | // because it require [lang].js to be loaded. |
17 | 17 | if( mw.config.get ( 'wgContentLanguage' ) === opt.language ) { |
18 | | - test( "Grammar Test", function() { |
| 18 | + test( "-- Grammar Test for "+ opt.language, function() { |
19 | 19 | expect( opt.test.length); |
20 | 20 | for ( var i= 0 ; i < opt.test.length; i++ ) { |
21 | 21 | equal( mw.language.convertGrammar( opt.test[i].word, opt.test[i].grammarForm ), opt.test[i].expected, opt.test[i].description ); |
— | — | @@ -58,3 +58,28 @@ |
59 | 59 | { word: 'ժամանակի', grammarForm: 'genitive', expected: 'ժամանակիի', description: 'Grammar test for Armenian, genitive case' } |
60 | 60 | ] |
61 | 61 | }); |
| 62 | + |
| 63 | +mw.language.grammartest({ |
| 64 | + language: 'fi', |
| 65 | + test: [ |
| 66 | + { word: 'talo', grammarForm: 'genitive', expected: 'talon', description: 'Grammar test for Finnish, genitive case' }, |
| 67 | + { word: 'linux', grammarForm: 'genitive', expected: 'linuxin', description: 'Grammar test for Finnish, genitive case' }, |
| 68 | + { word: 'talo', grammarForm: 'elative', expected: 'talosta', description: 'Grammar test for Finnish, elative case' }, |
| 69 | + { word: 'pastöroitu', grammarForm: 'elative', expected: 'pastöroitusta', description: 'Grammar test for Finnish, elative case' }, |
| 70 | + { word: 'talo', grammarForm: 'partitive', expected: 'taloa', description: 'Grammar test for Finnish, partitive case' }, |
| 71 | + { word: 'talo', grammarForm: 'illative', expected: 'taloon', description: 'Grammar test for Finnish, illative case' }, |
| 72 | + { word: 'linux', grammarForm: 'inessive', expected: 'linuxissa', description: 'Grammar test for Finnish, inessive case' } |
| 73 | + ] |
| 74 | +}); |
| 75 | + |
| 76 | +mw.language.grammartest({ |
| 77 | + language: 'ru', |
| 78 | + test: [ |
| 79 | + { word: 'честь', grammarForm: 'genitive', expected: 'честя', description: 'Grammar test for Russian, genitive case' }, |
| 80 | + { word: 'проведения', grammarForm: 'genitive', expected: 'проведении', description: 'Grammar test for Russian, genitive case' }, |
| 81 | + { word: 'Оснабрюка', grammarForm: 'genitive', expected: 'Оснабрюки', description: 'Grammar test for Russian, genitive case' }, |
| 82 | + { word: 'почти', grammarForm: 'genitive', expected: 'почтей', description: 'Grammar test for Russian, genitive case' }, |
| 83 | + { word: 'годы', grammarForm: 'genitive', expected: 'годов', description: 'Grammar test for Russian, genitive case' }, |
| 84 | + { word: 'песчаник', grammarForm: 'genitive', expected: 'песчаника', description: 'Grammar test for Russian, genitive case' } |
| 85 | + ] |
| 86 | +}); |
Index: branches/jsgrammar/resources/Resources.php |
— | — | @@ -670,6 +670,7 @@ |
671 | 671 | 'cu' => 'resources/mediawiki.language/languages/cu.js', |
672 | 672 | 'cy' => 'resources/mediawiki.language/languages/cy.js', |
673 | 673 | 'dsb' => 'resources/mediawiki.language/languages/dsb.js', |
| 674 | + 'fi' => 'resources/mediawiki.language/languages/fi.js', |
674 | 675 | 'fr' => 'resources/mediawiki.language/languages/fr.js', |
675 | 676 | 'ga' => 'resources/mediawiki.language/languages/ga.js', |
676 | 677 | 'gd' => 'resources/mediawiki.language/languages/gd.js', |
Index: branches/jsgrammar/resources/mediawiki.language/languages/ru.js |
— | — | @@ -21,3 +21,29 @@ |
22 | 22 | return forms[2]; |
23 | 23 | } |
24 | 24 | }; |
| 25 | + |
| 26 | +mediaWiki.language.convertGrammar = function( word, form ) { |
| 27 | + var grammarForms = mw.language.data[ 'ru' ].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 | + } |
| 49 | + return word; |
| 50 | +}; |
Index: branches/jsgrammar/resources/mediawiki.language/languages/fi.js |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +/** |
| 3 | + * Finnish (Suomi) language functions |
| 4 | + * @author Santhosh Thottingal |
| 5 | + */ |
| 6 | + |
| 7 | +mediaWiki.language.convertGrammar = function( word, form ) { |
| 8 | + var grammarForms = mw.language.data[ 'fi' ].get( 'grammarForms' ); |
| 9 | + if ( grammarForms && grammarForms[form] ) { |
| 10 | + return grammarForms[form][word] ; |
| 11 | + } |
| 12 | + |
| 13 | + // vowel harmony flag |
| 14 | + aou = word.match( /[aou][^äöy]*$/i ); |
| 15 | + |
| 16 | + if ( word.match( /wiki$/i ) ) { |
| 17 | + aou = false; |
| 18 | + } |
| 19 | + //append i after final consonant |
| 20 | + if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) |
| 21 | + word += 'i'; |
| 22 | + |
| 23 | + switch ( form ) { |
| 24 | + case 'genitive': |
| 25 | + word += 'n'; |
| 26 | + break; |
| 27 | + case 'elative': |
| 28 | + word += ( aou ? 'sta' : 'stä' ); |
| 29 | + break; |
| 30 | + case 'partitive': |
| 31 | + word += ( aou ? 'a' : 'ä' ); |
| 32 | + break; |
| 33 | + case 'illative': |
| 34 | + // Double the last letter and add 'n' |
| 35 | + word += word.substr( word.length-1 ) + 'n'; |
| 36 | + break; |
| 37 | + case 'inessive': |
| 38 | + word += ( aou ? 'ssa' : 'ssä' ); |
| 39 | + break; |
| 40 | + } |
| 41 | + return word; |
| 42 | +}; |
Property changes on: branches/jsgrammar/resources/mediawiki.language/languages/fi.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 43 | + native |