aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-26 13:56:08 -0800
committerAdam Soltys <[email protected]>2026-02-26 13:56:08 -0800
commite854eb48370dc3e3d7ac452ed31d648fb0cd3d9c (patch)
tree084838c2b377352284d1c4e9de166566b3c456db /src/lib
parenta5faa64ba470f935ea3e7932feece3cd9fbadb90 (diff)
downloadcoinos-ui-e854eb48370dc3e3d7ac452ed31d648fb0cd3d9c.tar.gz
coinos-ui-e854eb48370dc3e3d7ac452ed31d648fb0cd3d9c.zip
fix locale
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/utils.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 28b63038..dc239739 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -244,7 +244,7 @@ export const fd = async (req: Request): Promise<any> => {
return obj;
};
-const map = {
+export const localeMap = {
en: {
CAD: "en-CA",
USD: "en-US",
@@ -321,18 +321,18 @@ const map = {
export const loc = (user) => {
if (!user) return;
const { currency: c, language: l } = user;
- return map[l]?.[c] || map[c];
+ return localeMap[l]?.[c] || localeMap[c];
};
export const f = (
s: number,
currency: string,
- locale = "en-US",
+ locale = "",
minimumFractionDigits = 2,
maximumFractionDigits = 2,
) => {
- const l = typeof locale === "function" ? (locale as () => string)() : locale || "en-US";
const cur = currency || "USD";
+ const l = typeof locale === "function" ? (locale as () => string)() : locale || localeMap[cur] || "en-US";
const region = l.length >= 2 ? l.slice(-2) : "";
const currencyDisplay = region && cur.startsWith(region) ? "narrowSymbol" : "symbol";
return new Intl.NumberFormat(l, {