Figures format : internationalization

We have been reporting an issue regarding separators that are not well treated at the moment by the platform.
https://github.com/openfoodfoundation/openfoodnetwork/issues/796

So @maikel suggested here to come up with a more general solution to enable to use multiple separators for input.

I suggest we agree on what could be the different possibilities so that we cover all the cases in the fix. The idea is that the system should interpret, whatever the currency setting in “configuration”.

For example in France we have this as a current set up: “,” for decimal mark and " " (blank) for thousands separator.

But as when entered the figure are anyway displayed with the “.” decimal mark, some people to fill in anyway with a “.” as decimal mark, which then causes an issue (cf github issue at th beginning)

So @maikel idea was to enable multiple separators for inputs.
So in the case of France, we would say that we accept both , and . as decimal separators. We don’t have the issue for thousands separators, it’s always a blank or no separator so I don’t think there will be an issue.

For India @sreeharsha you said the separator for decimal is always “.”, but you need multiple separators for thousands, as you use either “,” or nothing. Maybe actually if you set up the thousands separator as “,” if people write 1230.30 it will be displayed correctly even if it doesn’t use the separator, so maybe you actually don’t need the thousands separator, no?

@CynthiaReynolds @tschumilas

I think it would be great also to have some form of error message if the amount is not filled in in the appropriate format, like if I fill in 24.000, the system should tell “amount no recognized, please enter it in the following format 12 345,50 €”

As I posted in the Github issue, it would be good to have a list of example as reference or specification. That’s what we came up with so far:

50.0   -> 50.00
50,00  -> 50.00
50,000 -> 50,000.00
5.00.0 -> error

As long as we have clear rules, it should be quite easy to implement.

Ok @maikel, so would it mean all entries will then be “converted” in the format on the right?
I guess people would understand, even if that’s not their usual format, and as long as they can fill in either in their own usual format or in the one displayed, I guess it’s ok…

Then I would add some cases

50.0 -> 50.00
50,0 -> 50.00
50,00 -> 50.00
50.00 -> 50.00 (this is the issue we have today, as we have set up the separator as ",’ and when a user write “50.00” it becomes “5000.00” cf github issue)
50,000 -> 50,000.00 > this is tricky, it could be a price with three decimals technically for France… although this is not usual
50.000 -> hum… this is tricky, can the . used for thousands separator in some countries? Then we don’t know if it means 50,000.00 or if it means 50.00 and someone has put 3 decimals
50,000.00 / 50,000.0 -> 50,000.00
50.000,00 / 50.000,0 -> 50,000.00
50.000.00 / 50.000.0 -> 50,000.00 (? I imagine…)
50 000 / 50 000,00 / 50 000,0 -> 50,000.00 (in France with use a blank as separator for thousands so people might leave a space as a thousand separator)
5.00.0 / 5.0.0 / 5.0.00 / 5.00.00 -> error
5,00.0 / 5,0.0 / 5,0.00 / 5,00.00 -> error
5.00,0 / 5.0,0 / 5.0,00 / 5.00,00 -> error

Should we consider the case when someone put 2 decimals? Is it something that might happen in some countries?

If I understand well, with that solution, there is no need anymore to configure any “currency decimal mark” or “currency thousands separator”, right @maikel ?
I’m a little concern about the UX of that solution though… it would mean that when I fill in a price like “12,5€” I will see in the table displayed “12.50”, well, I guess it’s ok. But it an be disturbing in some cases like if in France I fill in “50 000” and I see “50,000.00” displayed, well, I guess it will be understandable anyway, but not very usual… anyway, I think it’s acceptable in term of UX, even if not perfect, not really disturbing.

Any other case I forgot @sreeharsha @CynthiaReynolds @tschumilas @enricostn ?
We are happy to make that move forward in France.