feat: show usd price

This commit is contained in:
2024-12-18 09:47:35 +00:00
parent 3c4fe85694
commit 3e25743cdc
2 changed files with 34 additions and 12 deletions

View File

@ -3,6 +3,15 @@ export const DefaultLocale = "en-US";
export const getLocale = () => {
return (navigator.languages && navigator.languages[0]) ?? navigator.language ?? DefaultLocale;
};
export const getCurrency = () => {
const locale = navigator.language || navigator.languages[0];
const formatter = new Intl.NumberFormat(locale, {
style: "currency",
currency: "USD",
currencyDisplay: "code",
});
return formatter.formatToParts(1.2345).find(a => a.type === "currency")?.value ?? "USD";
};
export const AllLanguageCodes = [
"en",
"ja",