Countries JSON
Installation:
npm install countries-json --save
Usage example:
import countriesData from 'countries-json';
function getLang () {
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 () {
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());
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