aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parenta5faa64ba470f935ea3e7932feece3cd9fbadb90 (diff)
downloadcoinos-ui-e854eb48370dc3e3d7ac452ed31d648fb0cd3d9c.tar.gz
coinos-ui-e854eb48370dc3e3d7ac452ed31d648fb0cd3d9c.zip
fix locale
Diffstat (limited to 'src')
-rw-r--r--src/components/Numpad.svelte6
-rw-r--r--src/lib/utils.ts8
2 files changed, 7 insertions, 7 deletions
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte
index 4f04fbaa..5ba6e244 100644
--- a/src/components/Numpad.svelte
+++ b/src/components/Numpad.svelte
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from "svelte";
import Left from "$comp/Left.svelte";
- import { f, s, focus, warning, sat, sats } from "$lib/utils";
+ import { f, s, focus, warning, sat, sats, localeMap } from "$lib/utils";
import { t } from "$lib/translations";
import { fiat as fiatStore } from "$lib/store";
@@ -26,8 +26,8 @@
let symbol = $state("");
let position = $state("before");
- function getCurrencyInfo(locale: any = "en-US", currency: string) {
- const l = typeof locale === "function" ? locale() : locale || "en-US";
+ function getCurrencyInfo(locale: any = "", currency: string) {
+ const l = typeof locale === "function" ? locale() : locale || localeMap[currency] || "en-US";
const region = l.length >= 2 ? l.slice(-2) : "";
const currencyDisplay = region && currency.startsWith(region) ? "narrowSymbol" : "symbol";
const formatter = new Intl.NumberFormat(l, {
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, {