CiviCRM provides a utility class to help with formatting in a locale-aware way.
Money formatting is done by the brickmoney library.
Generally the format is derived from a combination of the currency and
Civi::format helper class is supported for use in extensions
to do this formatting. Some examples are:
||10,00 $ US|
||$10.00 (note no currency identifier)|
If no locale is provided then the fallback will use the setting
format_locale from 5.47 onwards, if set and if not then the site
language. Note that if the site is in (for example) New Zealand and is
using 'English (United States)' as the language it is probably important
to set the
format_locale to 'English (New Zealand)' or it will
think that NZD transactions need the currency to be output to
disambiguate the currency.
Note that if
format_locale is set then the brick money is
'in charge' of determining format and other currency localisation settings
(thousandSeparator, decimalSeparator) are ignored. There is also a
moneyFormat ('Monetary Amount Display') which is only respected by the legacy
method, which is being phased out.