-
Notifications
You must be signed in to change notification settings - Fork 4
Function.resolveCurrencyFormat
connor-baer edited this page Mar 28, 2025
·
75 revisions
@sumup-oss/intl / resolveCurrencyFormat
resolveCurrencyFormat(
locales?,currency?,options?):null|NumberFormat
Defined in: lib/number-format/index.ts:370
Resolves the locale and collation options that are used to format a number in the country's official currency.
| Parameter | Type |
|---|---|
locales? |
string | string[] |
currency? |
string |
options? |
NumberFormatOptions |
null | NumberFormat
import { resolveCurrencyFormat } from '@sumup-oss/intl';
resolveCurrencyFormat();
// {
// 'locale': 'en-US',
// 'numberingSystem': 'latn',
// 'style': 'currency',
// 'currency': 'USD',
// 'currencyDisplay': 'symbol',
// 'minimumIntegerDigits': 1,
// 'minimumFractionDigits': 2,
// 'maximumFractionDigits': 2,
// 'useGrouping': true,
// 'groupDelimiter': '.',
// 'decimalDelimiter': ',',
// 'currencySymbol': '$',
// 'currencyPosition': 'prefix',
// }
resolveCurrencyFormat('ja-JP');
// {
// 'locale': 'ja-JP',
// 'numberingSystem': 'latn',
// 'style': 'currency',
// 'currency': 'JPY',
// 'currencyDisplay': 'symbol',
// 'minimumIntegerDigits': 1,
// 'minimumFractionDigits': 0,
// 'maximumFractionDigits': 0,
// 'useGrouping': true,
// 'groupDelimiter': ',',
// 'decimalDelimiter': undefined,
// 'currencySymbol': '¥',
// 'currencyPosition': 'prefix',
// }
resolveCurrencyFormat('en-GB', { currencyDisplay: 'name' });
// {
// 'locale': 'en-GB',
// 'numberingSystem': 'latn',
// 'style': 'currency',
// 'currency': 'GBP',
// 'currencyDisplay': 'symbol',
// 'minimumIntegerDigits': 1,
// 'minimumFractionDigits': 2,
// 'maximumFractionDigits': 2,
// 'useGrouping': true,
// 'groupDelimiter': ',',
// 'decimalDelimiter': '.',
// 'currencySymbol': 'British pounds',
// 'currencyPosition': 'suffix',
// }For convenience, groupDelimiter,decimalDelimiter, currencySymbol, and
currencyPosition are returned in addition to the
Intl.ResolvedNumberFormatOptions.
In runtimes that don't support the Intl.NumberFormat.resolvedOptions API,
null is returned.
The COP and HUF currencies are formatted without decimals.