TelegramPWA/src/util/formatCurrency.ts
2021-08-16 14:21:22 +03:00

9 lines
280 B
TypeScript

import { LangCode } from '../types';
export function formatCurrency(totalPrice: number, currency?: string, locale: LangCode = 'en') {
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
}).format(currency === 'JPY' ? totalPrice : totalPrice / 100);
}