countryCurrencies.ts file exports an object that maps currency codes (ISO 4217) to an object containing the locale (countryLanguage) and the currency code (countryCurrency).countryCurrencies object has the currency code as its key (e.g., "BRL") and an object with the following structure as its value:typescript
interface CurrencyInfo {countryLanguage: string;countryCurrency: string;}
countryLanguage: A language and country code (e.g., pt-BR) that can be used with the Intl.NumberFormat API to format numbers.countryCurrency: The currency code (e.g., BRL), also used in formatting.typescript
import { countryCurrencies } from "./countryCurrencies";function formatToBRL(value: number) {const { countryLanguage, countryCurrency } = countryCurrencies.BRL;return new Intl.NumberFormat(countryLanguage, {style: "currency",currency: countryCurrency,}).format(value);}// Example output: R$ 1,234.56console.log(formatToBRL(1234.56));
json
{"BRL": {"countryLanguage": "pt-BR","countryCurrency": "BRL"}}