From: Amir E. Aharoni Date: Sun, 27 Sep 2015 07:34:25 +0000 (+0300) Subject: Update grammar rules and test for Ukrainian X-Git-Tag: 1.31.0-rc.0~9740^2~1 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=5ccbaf2c48b55f3da85867b2cf2e29645381e77a;p=lhc%2Fweb%2Fwiklou.git Update grammar rules and test for Ukrainian The grammar rules for Ukrainian have several mistakes. This is the first in a series of commits that fix this. * Add grammar tests for PHP. There weren't any tests at all, and now there are some. Not tests are added for rules that are wrong and irrelevant and will be removed in subsequent commits. * Add tests for JavaScript, and update a grammar rule that was incorrectly copied from Russian. Change-Id: I6de4581e2908eba39b33a13b07d048a34a3bd803 --- diff --git a/resources/src/mediawiki.language/languages/uk.js b/resources/src/mediawiki.language/languages/uk.js index a22874b35f..2e17808a4e 100644 --- a/resources/src/mediawiki.language/languages/uk.js +++ b/resources/src/mediawiki.language/languages/uk.js @@ -18,8 +18,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { word = word.slice( 0, -2 ) + 'ки'; } else if ( word.slice( -2 ) === 'ти' ) { word = word.slice( 0, -2 ) + 'тей'; - } else if ( word.slice( -2 ) === 'ды' ) { - word = word.slice( 0, -2 ) + 'дов'; + } else if ( word.slice( -2 ) === 'ди' ) { + word = word.slice( 0, -2 ) + 'дів'; } else if ( word.slice( -3 ) === 'ник' ) { word = word.slice( 0, -3 ) + 'ника'; } diff --git a/tests/phpunit/languages/classes/LanguageUkTest.php b/tests/phpunit/languages/classes/LanguageUkTest.php index 9051bcff6f..bd3e5603cd 100644 --- a/tests/phpunit/languages/classes/LanguageUkTest.php +++ b/tests/phpunit/languages/classes/LanguageUkTest.php @@ -69,4 +69,32 @@ class LanguageUkTest extends LanguageClassesTestCase { array( 'other', 121 ), ); } + + /** + * @dataProvider providerGrammar + * @covers Language::convertGrammar + */ + public function testGrammar( $result, $word, $case ) { + $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) ); + } + + public static function providerGrammar() { + return array( + array( + 'Вікіпедії', + 'Вікіпедія', + 'genitive', + ), + array( + 'Віківидів', + 'Віківиди', + 'genitive', + ), + array( + 'Вікіпедію', + 'Вікіпедія', + 'accusative', + ), + ); + } } diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js index c71111fcc0..fcbcada4aa 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js @@ -378,9 +378,9 @@ description: 'Grammar test for genitive case' }, { - word: 'доводы', + word: 'Віківиди', grammarForm: 'genitive', - expected: 'доводов', + expected: 'Віківидів', description: 'Grammar test for genitive case' }, {