Closed Swatinem closed 5 years ago
Now that I thought more about this, and also looked at how fluent does currency formatting, I think it would be a good idea to just introduce a proper currency
type, which is defined as {value: number, code: ISO4217 | string}
and always define the currency via code instead of via the translation.
So what is left would be:
declare const price: { value: number, code: string }
const translations = [
"{price, number, currency}",
"{price, number, currency0}",
"{price, number, currencycode}",
]
The support for currency formatting in messageformat is lacking :-( https://formatjs.io/guides/message-syntax/#custom-formats
I propose the following special custom formats (assuming locale
de
):currency:EUR
,currency:$code
currency0
code
instead of the defaultsymbol
:currencycode
All permutations of these should be supported, for example
currencycode0:$code
Examples:
{value, number, currency:EUR}
will result in10,00 €
{value, number, currency:$code}
will result in10 ¥
when passing{ code: 'JPY' }
{value, number, currency0:EUR}
will result in10 €
{value, number, currencycode:EUR}
will result in10,00 EUR