Using it-IT in language settings results in crazy numbers in fluoro detail
Summary box has missing numbers and numbers that are many orders of magnitude too large, likewise for event doses.
Not tested yet but assumed to affect all languages that use a comma for decimal marker.
Comments (23)
-
reporter -
I got a bit nervous as I'm living in a country that uses a comma for decimal marker. The server I'm running OpenREM on is set like this in Windows, but imports seem fine (and also summary boxes are fine). Or do you mean the language code in settings.py? In the settings.py the language code is not changed in my case (so still on 'en-us').
-
reporter I do mean the language code in settings.py
-
reporter Or local_settings.py actually
-
reporter For the filtered page, this line prevents or renders incorrectly the total dose at reference point: https://bitbucket.org/openrem/openrem/src/739bdcfee7fd9b65f33347d6307638eb7f5accdd/openrem/remapp/templates/remapp/rffiltered.html?at=develop&fileviewer=file-view-default#rffiltered.html-200
<script>document.write({{ accum_integrated.dose_rp_total }}.toPrecision(3));</script>
-
reporter This will get the right number on the page, but we'd end up with a mix of comma and decimal separators for the European localisations:
{% load l10n %} <script>document.write({{ accum_integrated.dose_rp_total|unlocalize }}.toPrecision(3));</script>
Thoughts anyone?
-
reporter I can just turn off localisation for the page, so that all the number formats are the same throughout. Seems a bit blunt though.
-
I didn't test it, but would
<script>document.write({{ accum_integrated.dose_rp_total | floatformat:3 }});</script>
do the trick? So use the Django functionality instead of the java toPrecision?
-
reporter I think
floatformat
will give decimal places, whereastoPrecision
gives significant figures -
aah, of course, then this one could do the trick probably: https://djangosnippets.org/snippets/1372/
-
reporter Perfect. I'll give it a try later - if we can use that then we can drop all the javascript formatting :-) However, it might fall foul of the commas too, we'll have to have a look.
-
reporter With a bit of modification, this works! Will push commits later
-
reporter Added filter snippet to set significant figures. From https://djangosnippets.org/snippets/1372/ but edited to deal with "0E-12" and to return a Decimal that can be localised. Refs
#693→ <<cset 6452d23227a7>>
-
reporter Tested with various values to trigger the issue avoided by testing for greater than 0 - issue is taking a
log10
of 0, so<0
test is good. -
reporter Updating sigdig to work with negative numbers as pointed out by @dplatten. Thanks! refs
#693→ <<cset 38c215619c24>>
-
reporter Better handling of zero, works for negative numbers. Refs
#693→ <<cset 00ebac26a20f>>
-
reporter Added ref
#693to changes. [skip ci] docs only→ <<cset 72a2842e4cf6>>
-
reporter Adding check for None. Should fix pipeline fail. Credit to @LuukO. Refs
#693→ <<cset 3c196d7b89bf>>
-
reporter -
assigned issue to
-
assigned issue to
-
reporter Returning empty string instead of not returning to normalise against floatformat. Credit to @LuukO. Refs
#693→ <<cset 621442809acb>>
-
reporter Adding module and function docs strings. Refs
#693→ <<cset 52a3e79d24a9>>
-
reporter - changed milestone to 0.9.0
-
reporter - changed status to resolved
Merged in issue693commadisplay (pull request #249) Fixes
#693Approved-by: Luuk
→ <<cset ab8bb902999a>>
- Log in to comment
There are numbers missing on the filtered list pages too if it-IT is used.
@dplatten, @LuukO, anyone, if you fancy working out what is going on and you might get there sooner than me, please do! Otherwise I'll see if I can work it out later.