*/
/**
+ * Lithuanian plural forms as per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#lt
* @param $count int
* @param $forms array
*
*/
function convertPlural( $count, $forms ) {
if ( !count( $forms ) ) { return ''; }
-
- // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
- if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
-
$forms = $this->preConvertPlural( $forms, 3 );
-
+ // Form[0] if n mod 10 is 1 and n mod 100 not in 11..19;
if ( $count % 10 == 1 && $count % 100 != 11 ) return $forms[0];
+ // Forms[1] if n mod 10 in 2..9 and n mod 100 not in 11..19;
if ( $count % 10 >= 2 && ( $count % 100 < 10 || $count % 100 >= 20 ) ) return $forms[1];
return $forms[2];
}
--- /dev/null
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageLt.php */
+class LanguageLtTest extends MediaWikiTestCase {
+ private $lang;
+
+ function setUp() {
+ $this->lang = Language::factory( 'Lt' );
+ }
+ function tearDown() {
+ unset( $this->lang );
+ }
+
+ function testPlural() {
+ $forms = array( 'one', 'few', 'other' );
+ $this->assertEquals( 'other', $this->lang->convertPlural( 0, $forms ) );
+ $this->assertEquals( 'one', $this->lang->convertPlural( 1, $forms ) );
+ $this->assertEquals( 'few', $this->lang->convertPlural( 2, $forms ) );
+ $this->assertEquals( 'few', $this->lang->convertPlural( 9, $forms ) );
+ $this->assertEquals( 'other', $this->lang->convertPlural( 10, $forms ) );
+ $this->assertEquals( 'other', $this->lang->convertPlural( 11, $forms ) );
+ $this->assertEquals( 'other', $this->lang->convertPlural( 20, $forms ) );
+ $this->assertEquals( 'one', $this->lang->convertPlural( 21, $forms ) );
+ $this->assertEquals( 'few', $this->lang->convertPlural( 32, $forms ) );
+ $this->assertEquals( 'one', $this->lang->convertPlural( 41, $forms ) );
+ $this->assertEquals( 'one', $this->lang->convertPlural( 40001, $forms ) );
+ $forms = array( 'one', 'few' );
+ $this->assertEquals( 'one', $this->lang->convertPlural( 1, $forms ) );
+ $this->assertEquals( 'few', $this->lang->convertPlural( 15, $forms ) );
+ }
+}