UNPKG

cheetah-framework

Version:

Cheetah Framework JS used in all our applications

20 lines (15 loc) 579 B
import i18n from '@cheetah/i18n' export default class Currency { static format (amount, currency) { if (amount === undefined || amount === null) { return '-' } if (!currency) { return Intl.NumberFormat(cheetahApp.locale).format(amount, { maximumFractionDigits: 2 }) } if (currency.length > 3) { return Intl.NumberFormat(cheetahApp.locale).format(amount, { maximumFractionDigits: 2 }) + ' ' + i18n.t('currency_' + currency) } return new Intl.NumberFormat(cheetahApp.locale, { style: 'currency', currency }).format(amount) } }