
Security News
Feross on TBPN: Socket's Series C and the State of Software Supply Chain Security
Feross Aboukhadijeh joins TBPN to discuss Socket's $60M Series C, 500%+ ARR growth, AI's impact on open source, and the rise in supply chain attacks.
locale-currency
Advanced tools
A map of locale codes to ISO 4217 currency codes. Supports BCP 47, i18n, and ISO 3166-1 alpha-2 formats.
A map of locale codes to ISO 4217 currency codes. Supports BCP 47, i18n, and ISO 3166-1 alpha-2 locale formats.
zh-Hant-TW, en-US, pt-BR)en_US, zh_TW)US, GB, TW)The library intelligently extracts the country/region code from complex locale strings to determine the appropriate currency.
npm install locale-currency
import { getCurrency, getLocales } from 'locale-currency';
// Get currency for a locale
getCurrency('US'); // 'USD'
getCurrency('en-US'); // 'USD'
getCurrency('en_US'); // 'USD'
getCurrency('zh-Hant-TW'); // 'TWD' - BCP 47 format
getCurrency('GB'); // 'GBP'
getCurrency('ES'); // 'EUR'
// Get all countries that use a currency
const euroCountries = getLocales('EUR');
// ['AD', 'AT', 'BE', 'CY', 'DE', 'EE', 'ES', 'FI', 'FR', 'GR', ...]
const { getCurrency, getLocales } = require('locale-currency');
getCurrency('en-US'); // 'USD'
getCurrency(locale: string): string | nullReturns the ISO 4217 currency code for a given locale, or null if not found.
locale - BCP 47, i18n, or ISO 3166-1 alpha-2 code'USD', 'EUR') or nullgetLocales(currencyCode: string): string[]Returns an array of ISO 3166-1 alpha-2 country codes that use the given currency.
currencyCode - ISO 4217 currency code (e.g., 'USD', 'EUR')import { getCurrency, getLocales } from 'locale-currency';
// Case insensitive
getCurrency('us'); // 'USD'
getCurrency('US'); // 'USD'
getCurrency('Us'); // 'USD'
// i18n format with underscores
getCurrency('EN_US'); // 'USD'
getCurrency('en_us'); // 'USD'
// BCP 47 format with hyphens
getCurrency('EN-US'); // 'USD'
getCurrency('en-us'); // 'USD'
// Complex BCP 47 with script code
getCurrency('zh-Hant-TW'); // 'TWD' (Traditional Chinese in Taiwan)
getCurrency('zh-Hans-CN'); // 'CNY' (Simplified Chinese in China)
// Direct country codes
getCurrency('GB'); // 'GBP'
getCurrency('ES'); // 'EUR'
getCurrency('GR'); // 'EUR'
// Find countries using Euro
const euroCountries = getLocales('EUR');
console.log(euroCountries.includes('GR')); // true (Greece)
console.log(euroCountries.includes('FR')); // true (France)
console.log(euroCountries.includes('ES')); // true (Spain)
FAQs
A map of locale codes to ISO 4217 currency codes. Supports BCP 47, i18n, and ISO 3166-1 alpha-2 formats.
The npm package locale-currency receives a total of 103,102 weekly downloads. As such, locale-currency popularity was classified as popular.
We found that locale-currency demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Feross Aboukhadijeh joins TBPN to discuss Socket's $60M Series C, 500%+ ARR growth, AI's impact on open source, and the rise in supply chain attacks.

Security News
OSV withdrew 157 OSV malware reports after automated false positives incorrectly flagged trusted npm and PyPI packages, sending bad records into tools that rely on OSV data.

Research
/Security News
TrapDoor crypto stealer hits 36 malicious packages across npm, PyPI, and Crates.io, targeting crypto, DeFi, AI, and security developers.