filters: formatCurrency

This commit is contained in:
He4eT 2025-04-30 23:19:11 +02:00
commit 43eea3538a

View file

@ -0,0 +1,15 @@
/**
* Format the number to the currency string according the page.lang
* Usage: {{ 10000 | formatCurrency: 'RDS' }} => '10 000 RSD'
*
* @param {number} amount
* @param {string} currency
* @returns {string}
*/
export function formatCurrency (amount, currency) {
const formatter = new Intl.NumberFormat(this.page.lang, {
style: 'currency',
currency,
})
return formatter.format(amount)
}