jenkins-bot has submitted this change and it was merged.
Change subject: Fix Language::parseFormattedNumber for lzh and zh-classical
..
Fix Language::parseFormattedNumber for lzh and zh-classical
When parsing, filter any array values that are empty string
before using strtr php function so that strtr can handle
the array.
Bug: 64347
Change-Id: I94761caa70d44febfa0999c91048a01044fc1fbe
---
M languages/Language.php
M tests/phpunit/languages/LanguageTest.php
2 files changed, 28 insertions(+), 1 deletion(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/languages/Language.php b/languages/Language.php
index c635ebb..95bd31e 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -3130,14 +3130,18 @@
* @param string $number
* @return string
*/
- function parseFormattedNumber( $number ) {
+ public function parseFormattedNumber( $number ) {
$s = $this->digitTransformTable();
if ( $s ) {
+ // eliminate empty array values such as ''. (bug 64347)
+ $s = array_filter( $s );
$number = strtr( $number, array_flip( $s ) );
}
$s = $this->separatorTransformTable();
if ( $s ) {
+ // eliminate empty array values such as ''. (bug 64347)
+ $s = array_filter( $s );
$number = strtr( $number, array_flip( $s ) );
}
diff --git a/tests/phpunit/languages/LanguageTest.php
b/tests/phpunit/languages/LanguageTest.php
index 13d84f7..ed89159 100644
--- a/tests/phpunit/languages/LanguageTest.php
+++ b/tests/phpunit/languages/LanguageTest.php
@@ -1473,6 +1473,29 @@
}
/**
+* @dataProvider parseFormattedNumberProvider
+*/
+ public function testParseFormattedNumber( $langCode, $number ) {
+ $lang = Language::factory( $langCode );
+
+ $localisedNum = $lang->formatNum( $number );
+ $normalisedNum = $lang->parseFormattedNumber( $localisedNum );
+
+ $this->assertEquals( $number, $normalisedNum );
+ }
+
+ public function parseFormattedNumberProvider() {
+ return array(
+ array( 'de', 377.01 ),
+ array( 'fa', 334 ),
+ array( 'fa', 382.772 ),
+ array( 'ar', 1844 ),
+ array( 'lzh', 3731 ),
+ array( 'zh-classical', 7432 )
+ );
+ }
+
+ /**
* @covers Language::commafy()
* @dataProvider provideCommafyData
*/
--
To view, visit https://gerrit.wikimedia.org/r/129369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I94761caa70d44febfa0999c91048a01044fc1fbe
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude
Gerrit-Reviewer: Addshore
Gerrit-Reviewer: Amire80
Gerrit-Reviewer: Aude
Gerrit-Reviewer: Daniel Kinzler
Gerrit-Reviewer: Hoo man
Gerrit-Reviewer: Nikerabbit
Gerrit-Reviewer: jenkins-bot <>
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits