https://bugzilla.wikimedia.org/show_bug.cgi?id=52426

       Web browser: ---
            Bug ID: 52426
           Summary: Make {{#expr: ... }} work with localized separators
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Keywords: i18n
          Severity: normal
          Priority: Unprioritized
         Component: ParserFunctions
          Assignee: [email protected]
          Reporter: [email protected]
    Classification: Unclassified
   Mobile Platform: ---

As reported on
https://www.mediawiki.org/wiki/Thread:Extension_talk:ParserFunctions/Use_comma_as_decimal_separator
and
https://pt.wikipedia.org/w/index.php?oldid=36562067&uselang=en#Re:_Casas_decimais_no_ParserFunctions
a code such as {{#expr: 1,5 * 3 }} doesn't work on ptwiki:
https://pt.wikipedia.org/w/index.php?oldid=36571994&uselang=en
(Expression error: Unrecognized punctuation character ",".)

Currently, we have the following on languages/messages/MessagesPt.php:
> $separatorTransformTable = array( ',' => "\xc2\xa0", '.' => ',' );
so, the character "," should be treated as the decimal separator, and the
result should be 4.5, as if the user had used {{#expr: 1.5 * 3 }} on enwiki.

A user suggested at
https://www.mediawiki.org/wiki/Thread:Extension_talk:ParserFunctions/Use_comma_as_decimal_separator/reply_(3)
the following change:
Add
> $expr = str_replace( ',', '.', $expr );
to the begin of ExprParser::doExpression() and replaced line 82 in
ExtParserFunctions::expr() with
> $result = self::getExprParser()->doExpression( $expr );
> $result = $parser->mOptions->mUserLang->formatNum( $result );
> return $result;
The first replaces all commas in a given expression with dots and the second
formats the output in the user language.

Could something like this be changed in the extension's code, for use on
Portuguese Wikipedia?

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to