Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koalex/countries-json
List of all countries with names and ISO 3166-1 codes in all languages in JSON.
https://github.com/koalex/countries-json
countries iso3166-1 json locales
Last synced: 23 days ago
JSON representation
List of all countries with names and ISO 3166-1 codes in all languages in JSON.
- Host: GitHub
- URL: https://github.com/koalex/countries-json
- Owner: koalex
- License: mit
- Created: 2019-01-20T12:18:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-20T13:47:25.000Z (almost 6 years ago)
- Last Synced: 2024-11-29T18:50:40.727Z (about 1 month ago)
- Topics: countries, iso3166-1, json, locales
- Language: JavaScript
- Size: 622 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Countries JSON
Installation:
```bash
npm install countries-json --save
```Usage example:
```javascript
import countriesData from 'countries-json'; // warning: files size with all locales ~3Mbfunction 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:```javascript
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](http://semver.org) for versioning. For the versions available, see the [tags on this repository](https://github.com/koalex/countries/tags).
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details