country-locale-map
Provides mapping between country codes and provides default country locals. Includes optional fuzzy matching for country name.
Last updated 2 months ago by atnmorrison .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install country-locale-map 
SYNC missed versions from official npm registry.

Country Locale Map Build Status

Provides easy conversion between country codes and names as well as a default locale for each country. Includes fuzzy matching for country name lookups.

Usage

const clm = require('country-locale-map');
clm.getAlpha3ByAlpha2('CA'); //returns 'CAN' 

Functions

Alpha2

  • getAlpha3ByAlpha2(alpha2)
clm.getAlpha3ByAlpha2('CA'); //returns 'CAN' 
  • getLocaleByAlpha2(alpha2)
clm.getLocaleByAlpha2('CA'); //returns 'en_CA' 
  • getCountryNameByAlpha2(alpha2)
clm.getCountryNameByAlpha2('CA'); //returns 'Canada' 
  • getNumericByAlpha2(alpha2)
clm.getNumericByAlpha2('CA'); //returns '124' 
  • getCurrencyByAlpha2(alpha2)
clm.getCurrencyByAlpha2('CA'); //returns 'CAD' 
  • getCountryByAlpha2(alpha2)
clm.getCountryByAlpha2('CA'); 

/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"????????",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

Alpha3

  • getAlpha2ByAlpha3(alpha3)
clm.getAlpha3ByAlpha2('CAN'); //returns 'CA' 
  • getLocaleByAlpha3(alpha3)
clm.getLocaleByAlpha3('CAN'); //returns 'en_CA' 
  • getCountryNameByAlpha3(alpha3)
clm.getCountryNameByAlpha3('CAN'); //returns 'Canada' 
  • getNumericByAlpha3(alpha3)
clm.getNumericByAlpha3('CAN'); //returns '124' 
  • getCurrencyByAlpha3(alpha3)
clm.getCurrencyByAlpha3('CAN'); //returns 'CAD' 
  • getCountryByAlpha3(alpha3)
clm.getCountryByAlpha3('CAN');


/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"????????",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

Numeric

  • getAlpha2ByNumeric(numeric)
clm.getAlpha2ByNumeric('123'); //returns 'CA' 
  • getAlpha3ByNumeric(numeric)
clm.getAlpha3ByNumeric('124'); //returns 'CAN' 
  • getLocaleByNumeric(numeric)
clm.getLocaleByNumeric('124'); //returns 'en_CA' 
  • getCountryNameByNumeric(numeric)
clm.getCountryNameByNumeric('124'); //returns 'Canada' 
  • getCurrencyByNumeric(numeric)
clm.getCurrencyByNumeric('124'); //returns 'CAD' 
  • getCountryByNumeric(numeric)
clm.getCountryByNumeric('124');


/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"????????",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/


Name

  • getAlpha2ByName(country, fuzzy)
clm.getAlpha2ByName('Canada'); //returns 'CA' 
  • getAlpha3ByName(country, fuzzy)
clm.getAlpha3ByName('Canada'); //returns 'CAN' 
  • getLocaleByName(country, fuzzy)
clm.getLocaleByName('Canada'); //returns 'en_CA' 
  • getNumericByName(country, fuzzy)
clm.getNumericByName('Canada'); //returns '124' 
  • getCurrencyByName(country, fuzzy)
clm.getCurrencyByName('Canada'); //returns 'CAD' 
  • getCountryByName(country, fuzzy)
clm.getCountryByName('Canada');

/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"????????",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

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);

/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"????????",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

Current Tags

  • 1.4.8                                ...           latest (2 months ago)

38 Versions

  • 1.4.8                                ...           2 months ago
  • 1.4.7                                ...           6 months ago
  • 1.4.6                                ...           6 months ago
  • 1.4.5                                ...           7 months ago
  • 1.4.4                                ...           7 months ago
  • 1.4.3                                ...           7 months ago
  • 1.4.2                                ...           7 months ago
  • 1.4.1                                ...           7 months ago
  • 1.4.0                                ...           7 months ago
  • 1.3.2                                ...           7 months ago
  • 1.3.1                                ...           7 months ago
  • 1.3.0                                ...           7 months ago
  • 1.2.5                                ...           7 months ago
  • 1.2.4                                ...           7 months ago
  • 1.2.3                                ...           7 months ago
  • 1.2.2                                ...           7 months ago
  • 1.2.1                                ...           7 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.0                                ...           7 months ago
  • 1.0.11                                ...           8 months ago
  • 1.0.10                                ...           8 months ago
  • 1.0.9                                ...           8 months ago
  • 1.0.8                                ...           8 months ago
  • 1.0.6                                ...           8 months ago
  • 1.0.5                                ...           8 months ago
  • 1.0.4                                ...           8 months ago
  • 1.0.3                                ...           8 months ago
  • 1.0.2                                ...           8 months ago
  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           8 months ago
  • 0.1.5                                ...           8 months ago
  • 0.1.4                                ...           8 months ago
  • 0.1.3                                ...           8 months ago
  • 0.1.2                                ...           8 months ago
  • 0.1.1                                ...           8 months ago
  • 0.1.0                                ...           8 months ago
  • 0.0.2                                ...           8 months ago
  • 0.0.1                                ...           8 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |