2012-02-01 04:53:55 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* @author Amir E. Aharoni
|
|
|
|
|
* based on LanguageBe_tarask.php
|
|
|
|
|
* @copyright Copyright © 2012, Amir E. Aharoni
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.
This data is according to UTS #35 Rev 33.
Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser
Changes to the plural rules:
* Hebrew override removed since CLDR 24 matches with MW plural rules.
* Updated the syntax of overridden rules to TR35 Rev 33 for
Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
Samogitian (sgs).
* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.
* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
since CLDR 24 matches with MW rules. Updated and added more tests.
Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
Also for variants sr-ec and sr-el
* Macedonian (mk) used to count 11 as 'other' form.
CLDR 24 counts it as 'one'.
Not overriding, using CLDR 24 here.
Updated the tests. MW will not override this.
* Armenian (hy) used to count 0 as 'other'.
Now it is 'one' form.
Updated the tests. MW will not override this.
* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
satisifying the following formula is counted as zero:
n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
Examples: 0, 10~20, 30, 40, 50, 60, 100.
Updated the tests accordingly. Not overriding it in MW.
Users will see different plural form for the above numbers.
* Removed Ukranian custom plural rule since it match with MW
* Russian (ru) plural rules have a major change.
The 'few' form is merged with the 'other' form.
The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.
Effectively forms[1] and forms[2] are swapped.
This will affect the messages, and such messages
must be reviewed and updated. This change is not included in this patch and
wil be done separately.
Russian is the only remaining language class with convertPlural method overridden.
Notable impact on the exising messages:
* For languages ru, uk, be_tarask, sr, For the special case
of two plural forms and first mapped to 1 and rest to the other form, syntax like
{{plural:$1|1=one|other}} should be used.
For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz
CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.
Followup: e571717e06667228ec8d689be067e00bdd06d34d
Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-01 09:05:39 +00:00
|
|
|
/** Tests for Ukrainian */
|
2012-10-23 20:53:17 +00:00
|
|
|
class LanguageUkTest extends LanguageClassesTestCase {
|
2013-10-22 10:32:29 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
*/
|
|
|
|
|
public function testPlural( $result, $value ) {
|
2012-02-01 04:53:55 +00:00
|
|
|
$forms = array( 'one', 'few', 'many', 'other' );
|
2012-10-23 20:53:17 +00:00
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-02-01 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-03 08:37:14 +00:00
|
|
|
/**
|
|
|
|
|
* Test explicit plural forms - n=FormN forms
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
*/
|
|
|
|
|
public function testExplicitPlural() {
|
|
|
|
|
$forms = array( 'one', 'few', 'many', 'other', '12=dozen' );
|
|
|
|
|
$this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) );
|
|
|
|
|
$forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' );
|
|
|
|
|
$this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) );
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
* @covers Language::getPluralRuleType
|
|
|
|
|
*/
|
|
|
|
|
public function testGetPluralRuleType( $result, $value ) {
|
2013-01-25 01:10:37 +00:00
|
|
|
$this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
public static function providePlural() {
|
2013-03-25 23:27:14 +00:00
|
|
|
return array(
|
2012-02-01 04:53:55 +00:00
|
|
|
array( 'one', 1 ),
|
|
|
|
|
array( 'many', 11 ),
|
|
|
|
|
array( 'one', 91 ),
|
|
|
|
|
array( 'one', 121 ),
|
|
|
|
|
array( 'few', 2 ),
|
|
|
|
|
array( 'few', 3 ),
|
|
|
|
|
array( 'few', 4 ),
|
|
|
|
|
array( 'few', 334 ),
|
|
|
|
|
array( 'many', 5 ),
|
|
|
|
|
array( 'many', 15 ),
|
|
|
|
|
array( 'many', 120 ),
|
|
|
|
|
);
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider providePluralTwoForms
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
*/
|
|
|
|
|
public function testPluralTwoForms( $result, $value ) {
|
Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.
This data is according to UTS #35 Rev 33.
Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser
Changes to the plural rules:
* Hebrew override removed since CLDR 24 matches with MW plural rules.
* Updated the syntax of overridden rules to TR35 Rev 33 for
Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
Samogitian (sgs).
* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.
* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
since CLDR 24 matches with MW rules. Updated and added more tests.
Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
Also for variants sr-ec and sr-el
* Macedonian (mk) used to count 11 as 'other' form.
CLDR 24 counts it as 'one'.
Not overriding, using CLDR 24 here.
Updated the tests. MW will not override this.
* Armenian (hy) used to count 0 as 'other'.
Now it is 'one' form.
Updated the tests. MW will not override this.
* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
satisifying the following formula is counted as zero:
n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
Examples: 0, 10~20, 30, 40, 50, 60, 100.
Updated the tests accordingly. Not overriding it in MW.
Users will see different plural form for the above numbers.
* Removed Ukranian custom plural rule since it match with MW
* Russian (ru) plural rules have a major change.
The 'few' form is merged with the 'other' form.
The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.
Effectively forms[1] and forms[2] are swapped.
This will affect the messages, and such messages
must be reviewed and updated. This change is not included in this patch and
wil be done separately.
Russian is the only remaining language class with convertPlural method overridden.
Notable impact on the exising messages:
* For languages ru, uk, be_tarask, sr, For the special case
of two plural forms and first mapped to 1 and rest to the other form, syntax like
{{plural:$1|1=one|other}} should be used.
For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz
CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.
Followup: e571717e06667228ec8d689be067e00bdd06d34d
Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-01 09:05:39 +00:00
|
|
|
$forms = array( '1=one', 'other' );
|
2012-10-23 20:53:17 +00:00
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-02-01 04:53:55 +00:00
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
public static function providePluralTwoForms() {
|
2013-02-15 10:27:48 +00:00
|
|
|
return array(
|
2012-02-01 04:53:55 +00:00
|
|
|
array( 'one', 1 ),
|
2013-01-25 01:10:37 +00:00
|
|
|
array( 'other', 11 ),
|
|
|
|
|
array( 'other', 91 ),
|
|
|
|
|
array( 'other', 121 ),
|
2012-02-01 04:53:55 +00:00
|
|
|
);
|
|
|
|
|
}
|
2015-09-27 07:34:25 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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',
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2012-02-01 04:53:55 +00:00
|
|
|
}
|