From 0a4c48eef92e45e5c12a7b8be321caf165fddb43 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 3 Feb 2026 21:46:49 -0800 Subject: accounts redesign --- src/lib/utils.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 33737b50..897b0f5a 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -334,16 +334,25 @@ export const f = ( locale = "en-US", minimumFractionDigits = 2, maximumFractionDigits = 2, -) => - new Intl.NumberFormat(locale, { +) => { + const l = typeof locale === "function" ? locale() : locale || "en-US"; + const cur = currency || "USD"; + const region = l.length >= 2 ? l.slice(-2) : ""; + const currencyDisplay = + region && cur.startsWith(region) ? "narrowSymbol" : "symbol"; + return new Intl.NumberFormat(l, { style: "currency", - currency: currency || "USD", + currency: cur, + currencyDisplay, minimumFractionDigits, maximumFractionDigits, }).format(s); +}; -export const s = (s: number, locale = "en-US"): string => - new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(s); +export const s = (s: number, locale = "en-US"): string => { + const l = typeof locale === "function" ? locale() : locale || "en-US"; + return new Intl.NumberFormat(l, { maximumFractionDigits: 0 }).format(s); +}; export const sat = (s: number): string => `${si(Math.abs(s)).toString()}`; -- cgit v1.2.3