New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18n-iso-countries

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-iso-countries

i18n for ISO 3166-1 country codes

1.15.1
Source
npm
Version published
Weekly downloads
796K
3.14%
Maintainers
1
Weekly downloads
 
Created

What is i18n-iso-countries?

The i18n-iso-countries npm package provides functionalities for working with ISO 3166-1 country codes. It allows you to get country names in different languages, convert between different country code formats, and validate country codes.

What are i18n-iso-countries's main functionalities?

Get Country Name by Alpha-2 Code

This feature allows you to get the name of a country given its Alpha-2 code. You can specify the language in which you want the country name.

const countries = require('i18n-iso-countries');
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
const countryName = countries.getName('US', 'en');
console.log(countryName); // Output: United States

Get Alpha-2 Code by Country Name

This feature allows you to get the Alpha-2 code of a country given its name. You can specify the language in which the country name is provided.

const countries = require('i18n-iso-countries');
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
const countryCode = countries.getAlpha2Code('United States', 'en');
console.log(countryCode); // Output: US

Validate Country Code

This feature allows you to validate whether a given country code is a valid ISO 3166-1 Alpha-2 code.

const countries = require('i18n-iso-countries');
const isValid = countries.isValid('US');
console.log(isValid); // Output: true

Get Country Names in All Languages

This feature allows you to get the names of all countries in a specified language.

const countries = require('i18n-iso-countries');
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
countries.registerLocale(require('i18n-iso-countries/langs/fr.json'));
const countryNames = countries.getNames('en');
console.log(countryNames); // Output: { 'AF': 'Afghanistan', 'AX': 'Åland Islands', ... }

Other packages similar to i18n-iso-countries

Keywords

i18n

FAQs

Package last updated on 09 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts