Thousands separator and decimal separator

181 views
Skip to first unread message

michim...@gmail.com

unread,
Jul 27, 2021, 7:07:43 AM7/27/21
to oTree help & discussion
Hi,

the thousands separators do not work anymore with otree lite. In addition, the decimal separators are no longer adapted to the language code (for me, there should be a comma in Germany). With the old otree this worked fine.

Best
Michael

Chris @ oTree

unread,
Jul 29, 2021, 12:49:21 AM7/29/21
to oTree help & discussion
For me the decimal separator is output properly as a comma when i set my language code to 'de'. Can you show some code that reproduces this issue?

USE_THOUSANDS_SEPARATOR is a Django setting and does not work with oTree 5. Maybe I will add support for something like that.

michim...@gmail.com

unread,
Jul 29, 2021, 4:50:36 AM7/29/21
to oTree help & discussion
Hi Chris,

thanks for your answer. a thousands separator support would be great. Here is my code for the language code problem:

# settings.py
LANGUAGE_CODE = 'de'

# __init.py__.py
class Constants(ConstantsTreatments):
    a = cu(5000)

def vars_for_template(player: Player):
     return dict(
        income_a=Constants.a,)

    
# template 
In dieser Periode beträgt Ihr Gewinn {{ income_a }}.

# Output
Output.JPG

Best
Michael

Chris @ oTree

unread,
Jul 29, 2021, 5:24:10 AM7/29/21
to oTree help & discussion
OK I see what you mean now. If you use points with POINTS_DECIMAL_PLACES, then I suppose it will always use a dot rather than a comma. I will put that on my list of things to fix. I guess I didn't notice that because I have de-emphasized POINTS_DECIMAL_PLACES in the documentation (in most cases I find it's better not to use it and just treat points as integers).

Anyway thank you for the feedback.

michim...@gmail.com

unread,
Jul 29, 2021, 6:52:22 AM7/29/21
to oTree help & discussion
Great, thank you very much.
Reply all
Reply to author
Forward
0 new messages