Gathering detailed insights and metrics for i18n-iso-countries
Gathering detailed insights and metrics for i18n-iso-countries
Gathering detailed insights and metrics for i18n-iso-countries
Gathering detailed insights and metrics for i18n-iso-countries
@shellscape/i18n-iso-countries
i18n for ISO 3166-1 country codes
country-codes-list
List of codes per country (languages, calling codes, currency codes, etc) with full TypeScript support.
@dior/i18n-iso-countries
i18n for ISO 3166-1 country codes
i18n-iso-util
A utility library for ISO-3166 codes
npm install i18n-iso-countries
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
99.6
Quality
82.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
102,880,338
Last Day
134,328
Last Week
585,122
Last Month
2,584,951
Last Year
33,104,818
828 Stars
386 Commits
261 Forks
13 Watching
4 Branches
131 Contributors
Minified
Minified + Gzipped
Latest Version
7.13.0
Package Id
i18n-iso-countries@7.13.0
Unpacked Size
604.24 kB
Size
164.95 kB
File Count
86
NPM Version
10.2.4
Node Version
20.11.0
Publised On
07 Nov 2024
Cumulative downloads
Total Downloads
Last day
-4.7%
134,328
Compared to previous day
Last week
-17.8%
585,122
Compared to previous week
Last month
10.8%
2,584,951
Compared to previous month
Last year
17.9%
33,104,818
Compared to previous year
1
5
i18n for ISO 3166-1 country codes. We support Alpha-2, Alpha-3 and Numeric codes from 'Wikipedia: Officially assigned code elements'
Install it using npm: npm install i18n-iso-countries
1var countries = require("i18n-iso-countries");
If you use i18n-iso-countries
with Node.js, you are done. If you use the package in a browser environment, you have to register the languages you want to use to minimize the file size.
1// Support french & english languages. 2countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3countries.registerLocale(require("i18n-iso-countries/langs/fr.json"));
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log("US (Alpha-2) => " + countries.getName("US", "en")); // United States of America 4console.log("US (Alpha-2) => " + countries.getName("US", "de")); // Vereinigte Staaten von Amerika 5console.log("USA (Alpha-3) => " + countries.getName("USA", "en")); // United States of America 6console.log("USA (Numeric) => " + countries.getName("840", "en")); // United States of America
1// Some countries have alias/short names defined. `select` is used to control which 2// name will be returned. 3console.log("GB (select: official) => " + countries.getName("GB", "en", {select: "official"})); // United Kingdom 4console.log("GB (select: alias) => " + countries.getName("GB", "en", {select: "alias"})); // UK 5console.log("GB (select: all) => " + countries.getName("GB", "en", {select: "all"})); // ["United Kingdom", "UK", "Great Britain"] 6// Countries without an alias will always return the offical name 7console.log("LT (select: official) => " + countries.getName("LT", "en", {select: "official"})); // Lithuania 8console.log("LT (select: alias) => " + countries.getName("LT", "en", {select: "alias"})); // Lithuania 9console.log("LT (select: all) => " + countries.getName("LT", "en", {select: "all"})); // ["Lithuania"]
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log(countries.getNames("en", {select: "official"})); // { 'AF': 'Afghanistan', 'AL': 'Albania', [...], 'ZM': 'Zambia', 'ZW': 'Zimbabwe' }
In case you want to add new language, please refer ISO 639-1 table.
af
: Afrikaansam
: Amharicar
: Arabicaz
: Azerbaijanibe
: Belorussianbg
: Bulgarianbn
: Bengalibr
: Bretonbs
: Bosnianca
: Catalancs
: Czechcy
: Cymraegda
: Danishde
: Germandv
: Dhivehien
: Englishes
: Spanishet
: Estonianeu
: Basquefa
: Persianfi
: Finnishfr
: Frenchga
: Irishgl
: Galicianel
: Greekha
: Hausahe
: Hebrewhi
: Hindihr
: Croatianhu
: Hungarianhy
: Armenianis
: Icelandicit
: Italianid
: Indonesianja
: Japaneseka
: Georgiankk
: Kazakhkm
: Khmerko
: Koreanku
: Kurdishky
: Kyrgyzlt
: Lithuanianlv
: Latvianmk
: Macedonianml
: Malayalammn
: Mongolianmr
: Marathims
: Malaymt
: Maltesenb
: Norwegian Bokmålnl
: Dutchnn
: Norwegian Nynorskno
: Norwegianpl
: Polishps
: Pashtopt
: Portuguesero
: Romanianru
: Russiansd
: Sindhisk
: Slovaksl
: Sloveneso
: Somalisq
: Albaniansr
: Serbiansv
: Swedishsw
: Swahilita
: Tamiltg
: Tajikth
: Thaitk
: Turkmentr
: Turkishtt
: Tatarug
: Uyghuruk
: Ukrainianur
: Urduuz
: Uzbekzh
: Chinesevi
: Vietnamese1var countries = require("i18n-iso-countries"); 2console.log("List of supported languages => " + countries.getSupportedLanguages()); 3// List of supported languages => ["cy", "dv", "sw", "eu", "af", "am", ...]
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log("United States of America => " + countries.getAlpha2Code("United States of America", "en")); 4// United States of America => US 5 6console.log("United States of America => " + countries.getAlpha3Code("United States of America", "en")); 7// United States of America => USA
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log("USA (Alpha-3) => " + countries.alpha3ToAlpha2("USA") + " (Alpha-2)"); 4// USA (Alpha-3) => US (Alpha-2)
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log("840 (Numeric) => " + countries.numericToAlpha2("840") + " (Alpha-2)"); 4// 840 (Numeric) => US (Alpha-2)
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log("DE (Alpha-2) => " + countries.alpha2ToAlpha3("DE") + " (Alpha-3)"); 4// DE (Alpha-2) => DEU (Alpha-3)
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log("840 (Numeric) => " + countries.numericToAlpha3("840") + " (Alpha-3)"); 4// 840 (Numeric) => USA (Alpha-3)
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log(countries.alpha3ToNumeric("SWE")); 4// 752
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log(countries.alpha2ToNumeric("SE")); 4// 752
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log(countries.getAlpha2Codes()); 4// { 'AF': 'AFG', 'AX': 'ALA', [...], 'ZM': 'ZMB', 'ZW': 'ZWE' }
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log(countries.getAlpha3Codes()); 4// { 'AFG': 'AF', 'ALA': 'AX', [...], 'ZMB': 'ZM', 'ZWE': 'ZW' }
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log(countries.getNumericCodes()); 4// { '004': 'AF', '008': 'AL', [...], '887': 'YE', '894': 'ZM' }
1var countries = require("i18n-iso-countries"); 2// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json")); 3console.log( 4 countries.isValid("US"), 5 countries.isValid("USA"), 6 countries.isValid("XX") 7); 8// true, true, false
To add a language:
npm run lint
and npm test
You can check codes here: https://www.iso.org/obp/ui/#home
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 18/30 approved changesets -- score normalized to 6
Reason
4 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More