mirror of
https://github.com/He4eT/xecut-site.git
synced 2026-05-04 17:37:26 +00:00
filters: formatCurrency
This commit is contained in:
parent
83c1f47ace
commit
ee8a5c5607
1 changed files with 15 additions and 0 deletions
15
src/_filters/formatCurrency.js
Normal file
15
src/_filters/formatCurrency.js
Normal 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)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue