-
Notifications
You must be signed in to change notification settings - Fork 11
Description
As we know from the Units & Symbols page in the guide, formatting currency amounts can be quite intricate, due to the many different standards across the world.
I dug into the current code for that in the QML app for this PR last week, and I think we need to tweak it a bit further. So I thought I'd start outlining the requirements here and we can refine and discuss.
Here's a visual overview.
AI tells me that QML has some utility functions that will not do the whole trick, but can be combined in some ways.
- Qt.formatCurrency(1234.56, "USD")
- Number.toLocaleString() - JavaScript's standard method works in QML
- Qt.locale() - Provides locale-specific formatting
With Qt.formatCurrency not supporting bitcoin out of the box, one option might be to create a USD String and then replace the $ symbol with ₿.
Another, more code-specific question was whether the formatting is specified by the view that is displaying the amount, or whether the model provides this. Due to the amount of variations we have, I'd recommend to keep this in each view. It could possible also just be a general component that wraps the logic. This approach would also make sense since users can switch formatting in the UI in a few places.
Anyhow, let me know what you think, especially @johnny9 as it comes to implementation. Thanks.