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
c959200095
commit
43eea3538a
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