Skip to content

List of all countries with names and ISO 3166-1 codes in all languages in JSON.

License

Notifications You must be signed in to change notification settings

koalex/countries-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Countries JSON

Installation:

npm install countries-json --save

Usage example:

import countriesData from 'countries-json'; // warning: files size with all locales ~3Mb

function getLang () { // browser
    if (navigator.languages !== undefined && navigator.languages.length) {
        return navigator.languages[0];
    } 
    return navigator.userLanguage || navigator.language || navigator.browserLanguage || navigator.systemLanguage;    
}

let countries = countriesData[getLang()]

console.log( countries );

or for single locale:

function getLang () { // browser
    if (navigator.languages !== undefined && navigator.languages.length) {
        return navigator.languages[0];
    } 
    return navigator.userLanguage || navigator.language || navigator.browserLanguage || navigator.systemLanguage;    
}

let countries = require('countries-json/data/' + getLang()); // load countries only for single locale

console.log( countries );

This project using SemVer for versioning. For the versions available, see the tags on this repository.

This project is licensed under the MIT License - see the LICENSE.md file for details

About

List of all countries with names and ISO 3166-1 codes in all languages in JSON.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published