New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sum format returns a space for Kiloseparator #248
Comments
**Observed result:** ...
Kilo separator is a space.
@jaideraf Could you comment here on the pr-br matter.
As defined in [0], I would expect the decimal as `,` (comma) and kilo
being a ` ` (space) therefore a number like `3,000.2` in English is
displayed in "português do Brasil" as `3 000,2`.
[0] SemanticMediaWiki/SemanticMediaWiki@e7dea7f
…On 6/22/17, Eduardo Elias ***@***.***> wrote:
### Setup
- MW version: 1.28.2
- DB (MySQL etc.): 10.2.6-MariaDB-10.2.6+maria~jessie
- PHP version:7.0.16 (fpm-fcgi)
- SMW version: 2.5.2
- SRF version: 2.5.0
- Browsers and versions (if applicable): ALL
### Issue
Sum format returns space for Kiloseparator.
**Steps to reproduce**
Use {{#ask: PARAMETER | format=sum}}
**Expected result:** ...
Either: with the kilo separator defined by the locale (in my case 'a dot')
Or: a standard number format (no kiloseparator and 'a dot' for decimal)
**Observed result:** ...
Kilo separator is a space.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#248
|
@mwjames |
When using |
When using `table` format all numbers are correctly formatted.
I'm confused now, or I misinterpreted the issue description.
I would expect (given the previously outlined rules of comma and
space) that a result for the number 3000.2 (ISO format) is displayed
both in `sum` and `table` format (for user language pt-br) as:
3 000,2
…On 6/22/17, Eduardo Elias ***@***.***> wrote:
When using `table` format all numbers are correctly formatted.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#248 (comment)
|
That's exactly the issue. It only shows Sum format: |
Here it works: https://is.gd/bK22hl |
Sum format: `3 000,02`
Table format: `3.000,02`
It depends on the changes to the SMW-core [0] (available with 2.5.3)
where space is defined as `smw_kiloseparator` for language pt-br and
would make both to be displayed
as:
`3 000,02`
Consequently it means that the current table format (2.5.2) shows the
wrong notation according to [0].
[0] SemanticMediaWiki/SemanticMediaWiki@e7dea7f
…On 6/22/17, Eduardo Elias ***@***.***> wrote:
>I would expect (given the previously outlined rules of comma and space)
> that a result for the number 3000.2 (ISO format) is displayed both in
> `sum` and `table` format (for user language pt-br) as:
> 3 000,2
That's exactly the issue. It only shows `space` for kiloseparator when I use
`sum` format. For `table` it works correctly.
Sum format: `3 000,02`
Table format: `3.000,02`
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#248 (comment)
|
I have altered my code adding the |
I have altered my code adding the `sw_kiloseparator` line just like the
patch, but using `.` instead. It didn't change anything. Is there any order
change that need to be done?
Now, I understand the issue. The math code uses the standard pt-br
language formatting from MediaWiki as:
```
// if raw-format ("-") than skip formatNum()
if ( $outputformat != "-" ) {
global $wgLang;
$number = $wgLang->formatNum( $number );
}
```
This overrides (or better neglects our custom smw_... keys) for the
SMW specific display formatting and just uses the plain user language
formatting.
…On 6/22/17, Eduardo Elias ***@***.***> wrote:
>It depends on the changes to the SMW-core [0] (available with 2.5.3) where
> space is defined as `smw_kiloseparator` for language pt-br and would make
> both to be displayed
I have altered my code adding the `sw_kiloseparator` line just like the
patch, but using `.` instead. It didn't change anything. Is there any order
change that need to be done?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#248 (comment)
|
This overrides (or better neglects our custom smw_... keys) for the
SMW specific display formatting and just uses the plain user language
If we wanted to make them behave equally then those lines would need
to be replaced with:
```
// if raw-format ("-") than skip formatNum()
if ( $outputformat != "-" ) {
- global $wgLang;
- $number = $wgLang->formatNum( $number );
+ $dataValue =
\SMW\DataValueFactory::getInstance()->newDataValueByType( '_num' );
+ $number = $dataValue->getLocalizedFormattedNumber( $number );
}
```
This relates to #202 (@jongfeli) and would require some integration
tests [0] before it can be green-lit to avoid introducing some form of
regression.
[0] https://github.com/SemanticMediaWiki/SemanticResultFormats/tree/master/tests/phpunit/Integration/JSONScript
…On 6/22/17, James HK ***@***.***> wrote:
> I have altered my code adding the `sw_kiloseparator` line just like the
> patch, but using `.` instead. It didn't change anything. Is there any
> order
> change that need to be done?
Now, I understand the issue. The math code uses the standard pt-br
language formatting from MediaWiki as:
```
// if raw-format ("-") than skip formatNum()
if ( $outputformat != "-" ) {
global $wgLang;
$number = $wgLang->formatNum( $number );
}
```
This overrides (or better neglects our custom smw_... keys) for the
SMW specific display formatting and just uses the plain user language
formatting.
On 6/22/17, Eduardo Elias ***@***.***> wrote:
>>It depends on the changes to the SMW-core [0] (available with 2.5.3)
>> where
>> space is defined as `smw_kiloseparator` for language pt-br and would
>> make
>> both to be displayed
>
> I have altered my code adding the `sw_kiloseparator` line just like the
> patch, but using `.` instead. It didn't change anything. Is there any
> order
> change that need to be done?
>
>
> --
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub:
> #248 (comment)
|
I will try that. Thank you. |
I actually have no longer any idea what the expected kilo separator for "pt-br" is. If a space is wrong it should be changed here. I am backing out of this. |
Not sure if the question is already clear... In Portuguese (and Brazilian Portuguese), decimal is used with a comma [1]. "Portuguese uses a dot to separate thousands, eg. 2.367.900 = 2,367,900" [2]
This shoud be presented as "336.397,5" or, better yet, "336.397,50" because it is a property for currency. [1] https://en.wikipedia.org/wiki/Decimal_mark#Hindu.E2.80.93Arabic_numeral_system |
The examples on wikipedia show a
[space]
MediaWiki's number formatting also uses spaces but [0, 1] shows a difference in:
- [0] European Portuguese to be `2 000`
- [1] Portuguese to be `2.000`
[0] http://www.unicode.org/cldr/charts/28/verify/numbers/pt_PT.html
[1] http://www.unicode.org/cldr/charts/28/verify/numbers/pt.html
PS: MediaWiki's number formatting uses the CLDR data as basis.
…On 6/22/17, Karsten Hoffmeyer ***@***.***> wrote:
The examples on wikipedia show a
[space](https://en.wikipedia.org/wiki/Decimal_mark#Examples_of_use) so I
added a "space". @jaideraf Please do me the favour and adjust at
translatewiki.net as it fits the "pt-br" needs.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#248 (comment)
|
@kghbln @mwjames I guess it is done now at translatewiki.net: [1][2][3][4] [1] https://translatewiki.net/wiki/MediaWiki:Smw_kiloseparator/pt-br (.) |
@jaideraf Thanks a lot. One already can have a hard time to figure this out for "de-ch" so "pt" and friends are even more difficult for non-natives. These changes will roll in next Tuesday and I will backport for fluff. |
Yes. That worked for me |
@mwjames I am trying to understand that JSON test thing to see if I can help a little, but I couldn't make it work. Why, at the wiki, the sum value is 30 030 025,75 but, in the test result, the sum value is 31 517 575? If it's not too wrong, maybe you could adjust this test to make it to work. {
"description": "Test for sum result format in pt-br lang",
"setup": [
{
"page": "MediaWiki:Smw_kiloseparator/pt-br",
"namespace": "NS_MEDIAWIKI",
"contents": "."
},
{
"page": "MediaWiki:Smw_decseparator/pt-br",
"namespace": "NS_MEDIAWIKI",
"contents": ","
},
{
"page": "Property:Has_number",
"namespace": "SMW_NS_PROPERTY",
"contents": "[[Has type::Number]]"
},
{
"page": "Has_number",
"namespace":"NS_MAIN",
"contents": "[[Has number::30000000]] [[Has number::15000]] [[Has number::15000,25]] [[Has number::25,50]] Sum: {{#show:{{PAGENAME}}|?Has number|format=sum}}"
}
],
"tests": [
{
"type": "parser",
"about": "#0 result format for sum in pt-br lang (test for kilo and decimal separators)",
"subject": "Has_number",
"assert-output": {
"to-contain": [
"30.030.025,75"
]
}
}
],
"settings": {
"wgContLang": "pt-br",
"wgLang": "pt-br",
"smwgNamespacesWithSemanticLinks": {
"NS_MAIN": true,
"SMW_NS_PROPERTY": true
}
},
"meta": {
"version": "2",
"is-incomplete": false,
"debug": false
}
} |
Thanks, I added [0] to clarify possible interferences when designing tests. As for the example, I'll wait until the translation arrives, then the modified test should pass. We are not relying on
|
Oh, much better, thanks. 👏 |
Addressed with #250. |
Setup
Issue
Sum format returns space for Kiloseparator.
Steps to reproduce
Use {{#ask: PARAMETER | format=sum}}
Expected result: ...
Either: with the kilo separator defined by the locale (in my case 'a dot')
Or: a standard number format (no kiloseparator and 'a dot' for decimal)
Observed result: ...
Kilo separator is a space.
The text was updated successfully, but these errors were encountered: