Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Locale Currency
https://github.com/tadeegan/locale-currency
Admin
A map of i18n country codes to ISO 4217 currency codes.
Tokens:
373
Snippets:
2
Trust Score:
8.8
License:
MIT
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Get Locales by Currency Code in Node.js Source: https://github.com/tadeegan/locale-currency/blob/master/README.md This example illustrates how to use the `LocaleCurrency.getLocales()` method to find all country codes associated with a specific ISO 4217 currency code. It verifies that common Eurozone countries like Greece, France, and Spain are correctly identified as using the 'EUR' currency. ```javascript var euroCountries = LocaleCurrency.getLocales("EUR"); assert(euroCountries.indexOf("GR") > -1); // Germany assert(euroCountries.indexOf("FR") > -1); // France assert(euroCountries.indexOf("ES") > -1); // Spain ``` -------------------------------- ### Get Currency Code by Locale in Node.js Source: https://github.com/tadeegan/locale-currency/blob/master/README.md This example demonstrates how to use the `LocaleCurrency.getCurrency()` method to retrieve the ISO 4217 currency code for various locale strings. It showcases the library's flexibility in handling different casing and format variations for country codes, returning the correct currency like USD, GBP, or EUR. ```javascript var LocaleCurrency = require('locale-currency'); var assert = require('assert'); assert(LocaleCurrency.getCurrency("us") === "USD"); assert(LocaleCurrency.getCurrency("US") === "USD"); assert(LocaleCurrency.getCurrency("Us") === "USD"); assert(LocaleCurrency.getCurrency("uS") === "USD"); assert(LocaleCurrency.getCurrency("EN_US") === "USD"); assert(LocaleCurrency.getCurrency("en_us") === "USD"); assert(LocaleCurrency.getCurrency("EN-US") === "USD"); assert(LocaleCurrency.getCurrency("en-us") === "USD"); assert(LocaleCurrency.getCurrency("GB") === "GBP"); assert(LocaleCurrency.getCurrency("ES") === "EUR"); assert(LocaleCurrency.getCurrency("GR") === "EUR"); ```