-
Notifications
You must be signed in to change notification settings - Fork 4
Function.formatCurrency
kodiakhq[bot] edited this page Nov 1, 2024
·
45 revisions
@sumup-oss/intl / formatCurrency
formatCurrency(
value
,locales
?,currency
?,options
?):string
Formats a number in the country's official currency with support for various notations.
Parameter | Type |
---|---|
value |
number |
locales ? |
string | string [] |
currency ? |
string |
options ? |
NumberFormatOptions |
string
import { formatCurrency } from '@sumup-oss/intl';
formatCurrency(12345.67, 'de-DE'); // '12.345,67 €'
formatCurrency(89, 'ja-JP', 'JPY'); // '¥89'
formatCurrency(16, 'en-GB', null, { currencyDisplay: 'name' }); // '16.00 British pounds'
In runtimes that don't support the Intl.NumberFormat
API, the currency is
formatted using the Number.toLocaleString
API.
The COP and HUF currencies are formatted without decimals.