@bodhiveggie/countries
Provides countries' locales, names, dial codes
Install
npm i -S @bodhiveggie/countries
Usage
Get countries info
import countries from '@bodhiveggie/countries/resources/countries.json';
// returns
/**
* [
* {
* "name": "China (中国)",
* "iso2": "cn",
* "dialCode": "86",
* "priority": 0,
* "areaCodes": null
* }
* ...
* ]
*/
Get country's flag image
const flag = require('@bodhiveggie/countries/resources/flags/us.png');
Get country's locale from iso2
NOTE: the locales used here were borrowed from
validator
pkg. Will default to 'en-US' if no locale was found for specifiediso2
import { getLocale } from '@bodhiveggie/countries';
getLocale('us');
// => 'en-US'
Get All locales
import { getAllLocales } from '@bodhiveggie/countries';
Get All ISO2 country codes
import { getAllIso2 } from '@bodhiveggie/countries';
getAllIso2();
// => ['US', 'CN', 'JP' ... ]
Get All Flags Images
import { getFlagImages } from '@bodhiveggie/countries';