diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-04-26 18:23:31 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-04-26 18:23:31 +0200 |
commit | c4372dd38a4d109b4f3881ea63b667e33adbe503 (patch) | |
tree | e8e6dae1229a68c26b7a348c73dc0c8c77da97e5 /extensions/ParserFunctions/Convert.php | |
parent | cf566324cfb218f0c7323d97d2a103bbb8d60ba4 (diff) |
Update to MediaWiki 1.18.3
Diffstat (limited to 'extensions/ParserFunctions/Convert.php')
-rw-r--r-- | extensions/ParserFunctions/Convert.php | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/extensions/ParserFunctions/Convert.php b/extensions/ParserFunctions/Convert.php index 2ae54d19..cdfd2232 100644 --- a/extensions/ParserFunctions/Convert.php +++ b/extensions/ParserFunctions/Convert.php @@ -54,6 +54,8 @@ class ConvertParser { # The last value converted, which will be used for PLURAL evaluation protected $lastValue; + protected $precision; + /** * Reset the parser so it isn't contaminated by the results of previous parses */ @@ -182,6 +184,19 @@ class ConvertParser { ); } + # If the Language hasn't been deliberately specified, get it from the wiki's + # content language, but run it through a configurable map first + if( $this->language === true ){ + global $wgContLang, $wgPFUnitLanguageVariants; + $code = $wgContLang->getCode(); + if( isset( $wgPFUnitLanguageVariants[$code] ) ){ + $this->language = Language::factory( $wgPFUnitLanguageVariants[$code] ); + } else { + # Ok, actually *do* use $wgContLang + $this->language = true; + } + } + return $this->processString( $string ); } @@ -217,13 +232,13 @@ class ConvertParser { if( $this->raw ){ return trim( $string ); } else { - $unit = $this->targetUnit->getText( + return $this->targetUnit->getText( + $string, $this->lastValue, $this->link, $this->abbreviate, $this->language ); - return $string . $unit; } } @@ -791,13 +806,14 @@ class ConvertUnit { /** * Get the text of the unit + * @param $string String Original text, with the number converted * @param $value String number for PLURAL support * @param $link Bool * @param $abbreviate Bool * @param $language Language * @return String */ - public function getText( $value, $link=false, $abbreviate=false, $language=null ){ + public function getText( $string, $value, $link=false, $abbreviate=false, $language=null ){ global $wgContLang; $value = $wgContLang->formatNum( $value ); @@ -806,7 +822,7 @@ class ConvertUnit { $this->dimension->getName(), $this->unitName, $this->prefix, - $value, $link, $abbreviate, $language + $string, $value, $link, $abbreviate, $language ); } elseif( !wfEmptyMsg( "pfunc-convert-unit-{$this->dimension->getName(true)}-{$this->unitName[0]}-{$this->unitName[1]}" ) ){ @@ -817,7 +833,7 @@ class ConvertUnit { $this->dimension->getName(true), "{$this->unitName[0]}-{$this->unitName[1]}", $this->prefix, # This will probably be rubbish, but it's the wiki users' problem, not ours - $value, $link, $abbreviate, $language + $string, $value, $link, $abbreviate, $language ); } else { @@ -826,12 +842,13 @@ class ConvertUnit { $dimensionNames[0], $this->unitName[0], $this->prefix[0], - $value, $link, $abbreviate, $language + $string, $value, $link, $abbreviate, $language ); $msg2Text = $this->getTextFromMessage( $dimensionNames[1], $this->unitName[1], $this->prefix[1], + '', 1, # Singular for denominator $link, $abbreviate, $language ); @@ -862,6 +879,7 @@ class ConvertUnit { $text = wfMsgExt( "pfunc-convert-unit-$dimension-$unit$abbr", array( 'parsemag', 'language' => $language ), + $string, $number, $prefix ); |