use Intl.NumberFormat to format currency

This commit is contained in:
Haben Amare 2020-05-25 22:05:06 +00:00
parent d26786a628
commit 8732e4b18f
7 changed files with 70 additions and 25 deletions

View file

@ -85,11 +85,16 @@ CardCustomField.register('cardCustomField');
onCreated() {
super.onCreated();
this.currencySymbol = this.data().definition.settings.currencySymbol;
this.currencyCode = this.data().definition.settings.currencyCode;
}
formattedValue() {
return `${this.currencySymbol}${this.data().value}`;
const locale = TAPi18n.getLanguage();
return new Intl.NumberFormat(locale, {
style: 'currency',
currency: this.currencyCode,
}).format(this.data().value);
}
events() {