docassemble icon indicating copy to clipboard operation
docassemble copied to clipboard

switch `currency` function from python locale to babel.numbers.format_currency

Open nonprofittechy opened this issue 4 years ago • 1 comments

This is thread safe and appears to be much easier to use when a single document switches back and forth between multiple currencies.

If this is of interest happy to submit a small PR

nonprofittechy avatar Jan 12 '21 15:01 nonprofittechy

I thought about using that function when I implemented currency() but I decided to go with the locale formatter even though it caused a thread safety issue. I don't remember all the reasons but one of them was that you need to pass the babel function a denomination, and while I could determine a denomination from get_territory_currencies(), sometimes that function returns multiple currencies, and then what do you do. Whereas with the OS there is an existing system for unambiguously mapping locale to currency, which is highly configurable. Also people still have lots of options because currency() accepts a symbol parameter and it is a language function that can be overridden.

In any case adopting the babel version could be a breaking change for people so I wouldn't implement it until a major version upgrade.

jhpyle avatar Jan 16 '21 00:01 jhpyle