Giter VIP home page Giter VIP logo

countryinfo's Introduction

country.

Build Status

country. provides all kinds of data on countries. It offers the following information:

  • ISO-3611-1/2/3 code
  • International Olympic Committee Code (IOC)
  • Spoken languages
  • Used currencies
  • Calling codes
  • Country Flag as an Emoji
  • Names in the following languages:
Code Language
ar Arabic
cs Czech
de German
en English
et Estonian
fi Finnish
fr French
it Italian
nb Norwegian Bokmål
nn Norwegian Nynorsk
nl Dutch
pl Polish
pt Portuguese
ru Russian
sv Swedish
tr Turkish
zh Chinese

This library also classifies countries into regions. The following regions are supported:

  • Asia (Central + Southern + Southeast + East + Western)

  • Central Asia

  • Southern Asia

  • Southeast Asia

  • East Asia

  • Western Asia

  • Africa (Central + North + Southern + East + West)

  • Central Africa

  • North Africa

  • Southern Africa

  • East Africa

  • West Africa

  • Europe (Northern + Southern + Eastern + Western)

  • Northern Europe

  • Southern Europe

  • Eastern Europe

  • Western Europe

  • America (Central + Northern + Southern)

  • Central America

  • Northern America

  • South America

  • Other

  • Australia

  • Melanesia

  • Micronesia

  • Polynesia

  • Antartica

  • Caribbean

Usage

Require country. in your project.

'use strict';
const country = require('countryinfo');

ISO 3166-1 codes

// ISO 3166-1 numeric identifiers from ...
country.iso1('DE');                 // ... ISO 3166-1 alpha-2
country.iso1('DEU');                // ... ISO 3166-1 alpha-3
country.iso1('Germany');            // ... country name
country.iso1('Deutschland', 'de');  // ... localized country name

// ISO 3166-1 alpha-2 identifiers from ...
country.iso2('276');                // ... ISO 3166-1 numeric
country.iso2('DEU');                // ... ISO 3166-1 alpha-3
country.iso2('Germany');            // ... country name
country.iso2('Deutschland', 'de');  // ... localized country name

// ISO 3166-1 alpha-3 identifiers from ...
country.iso3('276');                // ... ISO 3166-1 numeric
country.iso3('DE');                 // ... ISO 3166-1 alpha-2
country.iso3('Germany');            // ... country name
country.iso3('Deutschland', 'de');  // ... localized country name

IOC

// IOC identifiers from ...
country.ioc('276');                // ... ISO 3166-1 numeric
country.ioc('DE');                 // ... ISO 3166-1 alpha-2
country.ioc('DEU');                // ... ISO 3166-1 alpha-3
country.ioc('Germany');            // ... country name
country.ioc('Deutschland', 'de');  // ... localized country name

Languages

// Spoken languages from ...
country.languages('276');                // ... ISO 3166-1 numberic
country.languages('DE');                 // ... ISO 3166-1 alpha-2
country.languages('DEU');                // ... ISO 3166-1 alpha-3
country.languages('Germany');            // ... country name
country.languages('Deutschland', 'de');  // ... localized country name

Currencies

// Used currencies in country from ...
country.currencies('276');                // ... ISO 3166-1 numberic
country.currencies('DE');                 // ... ISO 3166-1 alpha-2
country.currencies('DEU');                // ... ISO 3166-1 alpha-3
country.currencies('Germany');            // ... country name
country.currencies('Deutschland', 'de');  // ... localized country name

Country data

// Complete data of country from ...
country.data('276');                // ... ISO 3166-1 numberic
country.data('DE');                 // ... ISO 3166-1 alpha-2
country.data('DEU');                // ... ISO 3166-1 alpha-3
country.data('Germany');            // ... country name
country.data('Deutschland', 'de');  // ... localized country name

Regions

// Region data
country.regions();                   // all regions
country.regionsData();               // all regions including data for all countries (ISO 3166-1 codes, IOC,...)
country.regions('europe');           // find region by identifier ...
country.regions('Central Asia');     // ... or by name
country.regionsData('europe');       // complete region data by identifier...
country.regionsData('Central Asia'); // ... or by name

Contribution & Data Sources

If you want to add additional country names to the list, feel free to do so in the /lib/data/names.json file. The structure should be clear.

{
	"DE": {                        // ISO 3166-1 alpha-2 identifier
		"en": ["Germany"],        // array of to be added names in the set locale
		"ar": [" ألمانيا"]
	}
}

To import the data into the library, run make in the root directory. This recreates the /lib/data/masterData.json file.

Data sources

I don't need a JS library, I just need the data.

Run make in the root directory of the project and copy the /lib/data/masterData.json file. This file contains all the mentioned data.

Build / Test / Update

In package json:

  • npm test - run tests
  • npm run cleaner - update master data

countryinfo's People

Contributors

andreisoroka avatar dependabot[bot] avatar ohitsdaniel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.