Country Locale Map
Provides easy conversion between country codes and names as well as a default locale for each country. Includes fuzzy matching for country name lookups.
Methods return undefined if no matches are found
Usage
const clm = require('country-locale-map');
clm.getAlpha3ByAlpha2('CA');
If you would like locales to be returned with - instead of_ you can set an environment variable
CLM_MODE='INTL' in a .env file using dotenv just make sure that dotenv is required before requiring the country local map library
Functions
Alpha2
- getAlpha3ByAlpha2(alpha2)
clm.getAlpha3ByAlpha2('CA');
- getLocaleByAlpha2(alpha2)
clm.getLocaleByAlpha2('CA');
- getCountryNameByAlpha2(alpha2)
clm.getCountryNameByAlpha2('CA');
- getNumericByAlpha2(alpha2)
clm.getNumericByAlpha2('CA');
- getCurrencyByAlpha2(alpha2)
clm.getCurrencyByAlpha2('CA');
- getCountryByAlpha2(alpha2)
clm.getCountryByAlpha2('CA');
Alpha3
- getAlpha2ByAlpha3(alpha3)
clm.getAlpha3ByAlpha2('CAN');
- getLocaleByAlpha3(alpha3)
clm.getLocaleByAlpha3('CAN');
- getCountryNameByAlpha3(alpha3)
clm.getCountryNameByAlpha3('CAN');
- getNumericByAlpha3(alpha3)
clm.getNumericByAlpha3('CAN');
- getCurrencyByAlpha3(alpha3)
clm.getCurrencyByAlpha3('CAN');
- getCountryByAlpha3(alpha3)
clm.getCountryByAlpha3('CAN');
Numeric
- getAlpha2ByNumeric(numeric)
clm.getAlpha2ByNumeric('123');
- getAlpha3ByNumeric(numeric)
clm.getAlpha3ByNumeric('124');
- getLocaleByNumeric(numeric)
clm.getLocaleByNumeric('124');
- getCountryNameByNumeric(numeric)
clm.getCountryNameByNumeric('124');
- getCurrencyByNumeric(numeric)
clm.getCurrencyByNumeric('124');
- getCountryByNumeric(numeric)
clm.getCountryByNumeric('124');
Name
- getAlpha2ByName(country, fuzzy)
clm.getAlpha2ByName('Canada');
- getAlpha3ByName(country, fuzzy)
clm.getAlpha3ByName('Canada');
- getLocaleByName(country, fuzzy)
clm.getLocaleByName('Canada');
- getNumericByName(country, fuzzy)
clm.getNumericByName('Canada');
- getCurrencyByName(country, fuzzy)
clm.getCurrencyByName('Canada');
- getCountryByName(country, fuzzy)
clm.getCountryByName('Canada');
if true is passed for fuzzy these functions will do a fuzzy match if it can't find an exact match eg:
clm.getCountryByName('Candaa', true);
clm.getAllCountries();