Skip to content

Commit

Permalink
fix: display amounts in non-three-letter currency codes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkeaton committed Jan 21, 2025
1 parent e88d19d commit 04ac096
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions src/boot/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ window.windowMixin = {
if (currency == "msat") return this.fromMsat(value);
if (currency == "usd") value = value / 100;
if (currency == "eur") value = value / 100;
return new Intl.NumberFormat(window.LOCALE, {
style: "currency",
currency: currency,
}).format(value);
// + " " +
// currency.toUpperCase()

if (currency.length !== 3) {
return new Intl.NumberFormat(window.LOCALE).format(value);
} else {
return new Intl.NumberFormat(window.LOCALE, {
style: "currency",
currency: currency,
}).format(value);
// + " " +
// currency.toUpperCase()
}
},
formatSat: function (value) {
// convert value to integer
Expand Down
17 changes: 11 additions & 6 deletions src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ export const useUiStore = defineStore("ui", {
if (currency == "msat") return this.fromMsat(value);
if (currency == "usd") value = value / 100;
if (currency == "eur") value = value / 100;
return new Intl.NumberFormat(navigator.language, {
style: "currency",
currency: currency,
}).format(value);
// + " " +
// currency.toUpperCase()

if (currency.length !== 3) {
return new Intl.NumberFormat(navigator.language).format(value);
} else {
return new Intl.NumberFormat(navigator.language, {
style: "currency",
currency: currency,
}).format(value);
// + " " +
// currency.toUpperCase()
}
},
toggleDebugConsole() {
this.showDebugConsole = !this.showDebugConsole;
Expand Down

0 comments on commit 04ac096

Please sign in to comment.