michaelwittig / Node I18n Iso Countries
Licence: mit
i18n for ISO 3166-1 country codes
Stars: ✭ 461
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Node I18n Iso Countries
Cluster Monitoring
Cluster monitoring stack for clusters based on Prometheus Operator
Stars: ✭ 453 (-1.74%)
Mutual labels: hacktoberfest
Hazelcast
Open-source distributed computation and storage platform
Stars: ✭ 4,662 (+911.28%)
Mutual labels: hacktoberfest
Thinkspace
Just another minimalist Jekyll theme which designed for technical writing blog.
Stars: ✭ 454 (-1.52%)
Mutual labels: hacktoberfest
Num2words
Modules to convert numbers to words. 42 --> forty-two
Stars: ✭ 454 (-1.52%)
Mutual labels: hacktoberfest
Heimdall
Self-hosted personal email guardian with one-step deployment
Stars: ✭ 459 (-0.43%)
Mutual labels: hacktoberfest
Serenata De Amor
🕵 Artificial Intelligence for social control of public administration
Stars: ✭ 4,367 (+847.29%)
Mutual labels: hacktoberfest
Csm
Source code for the Cities: Skylines Multiplayer mod (CSM)
Stars: ✭ 457 (-0.87%)
Mutual labels: hacktoberfest
Awesome Open Source Supporters
⭐️ A curated list of companies that offer their services for free to Open Source projects
Stars: ✭ 457 (-0.87%)
Mutual labels: hacktoberfest
Sde Interview Questions
Most comprehensive list 📋 of tech interview questions 📘 of companies scraped from Geeksforgeeks, CareerCup and Glassdoor.
Stars: ✭ 5,406 (+1072.67%)
Mutual labels: hacktoberfest
Neoalgo
Bringing all Data Structures and Algorithms under one Roof ⚡
Stars: ✭ 440 (-4.56%)
Mutual labels: hacktoberfest
Git Katas
A set of exercises for deliberate Git Practice
Stars: ✭ 453 (-1.74%)
Mutual labels: hacktoberfest
Skript
Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
Stars: ✭ 458 (-0.65%)
Mutual labels: hacktoberfest
Downloader For Apple Developers
Download Xcode, WWDC Videos, and other developer tools up to 16 times faster.
Stars: ✭ 456 (-1.08%)
Mutual labels: hacktoberfest
Nlp.js
An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more
Stars: ✭ 4,670 (+913.02%)
Mutual labels: hacktoberfest
Ruby Next
Ruby Next makes modern Ruby code run in older versions and alternative implementations
Stars: ✭ 460 (-0.22%)
Mutual labels: hacktoberfest
Wordpresscan
WPScan rewritten in Python + some WPSeku ideas
Stars: ✭ 456 (-1.08%)
Mutual labels: hacktoberfest
i18n-iso-countries
⚠️ Version 5 drops support for node 6 and 7!
i18n for ISO 3166-1 country codes. We support Alpha-2, Alpha-3 and Numeric codes from 'Wikipedia: Officially assigned code elements'
Installing
Install it using npm: npm install i18n-iso-countries
var 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.
// Support french & english languages.
countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
countries.registerLocale(require("i18n-iso-countries/langs/fr.json"));
Code to Country
Get the name of a country by its ISO 3166-1 Alpha-2, Alpha-3 or Numeric code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("US (Alpha-2) => " + countries.getName("US", "en", {select: "official"})); // United States of America
console.log("US (Alpha-2) => " + countries.getName("US", "de", {select: "official"})); // Vereinigte Staaten von Amerika
console.log("USA (Alpha-3) => " + countries.getName("USA", "en", {select: "official"})); // United States of America
console.log("USA (Numeric) => " + countries.getName("840", "en", {select: "official"})); // United States of America
Get all names by their ISO 3166-1 Alpha-2 code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getNames("en", {select: "official"})); // { 'AF': 'Afghanistan', 'AL': 'Albania', [...], 'ZM': 'Zambia', 'ZW': 'Zimbabwe' }
Supported languages (ISO 639-1)
In case you want to add new language, please refer ISO 639-1 table.
-
af
: Afrikaans -
am
: Amharic -
ar
: Arabic -
az
: Azerbaijani -
be
: Belorussian -
bg
: Bulgarian -
bn
: Bengali -
bs
: Bosnian -
ca
: Catalan -
cs
: Czech -
da
: Danish -
de
: German -
en
: English -
es
: Spanish -
et
: Estonian -
fa
: Persian -
fi
: Finnish -
fr
: French -
gl
: Galician -
el
: Greek -
ha
: Hausa -
he
: Hebrew -
hi
: Hindi -
hr
: Croatian -
hu
: Hungarian -
hy
: Armenian -
is
: Icelandic -
it
: Italian -
id
: Indonesian -
ja
: Japanese -
ka
: Georgian -
kk
: Kazakh -
km
: Khmer -
ko
: Korean -
ku
: Kurdish -
ky
: Kyrgyz -
lt
: Lithuanian -
lv
: Latvian -
mk
: Macedonian -
ml
: Malayalam -
mn
: Mongolian -
ms
: Malay -
nb
: Norwegian Bokmål -
nl
: Dutch -
nn
: Norwegian Nynorsk -
no
: Norwegian -
pl
: Polish -
ps
: Pashto -
pt
: Portuguese -
ro
: Romanian -
ru
: Russian -
sd
: Sindhi -
sk
: Slovak -
sl
: Slovene -
so
: Somali -
sq
: Albanian -
sr
: Serbian -
sv
: Swedish -
ta
: Tamil -
tg
: Tajik -
th
: Thai -
tr
: Turkish -
tt
: Tatar -
ug
: Uyghur -
uk
: Ukrainian -
ur
: Urdu -
uz
: Uzbek -
zh
: Chinese -
vi
: Vietnamese
Country to Code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(
"United States of America => " +
countries.getAlpha2Code("United States of America", "en")
);
// United States of America => US
console.log(
"United States of America => " +
countries.getAlpha3Code("United States of America", "en")
);
// United States of America => USA
Codes
Convert Alpha-3 to Alpha-2 code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(
"USA (Alpha-3) => " + countries.alpha3ToAlpha2("USA") + " (Alpha-2)"
);
// USA (Alpha-3) => US (Alpha-2)
Convert Numeric to Alpha-2 code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(
"840 (Numeric) => " + countries.numericToAlpha2("840") + " (Alpha-2)"
);
// 840 (Numeric) => US (Alpha-2)
Convert Alpha-2 to Alpha-3 code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log("DE (Alpha-2) => " + countries.alpha2ToAlpha3("DE") + " (Alpha-3)");
// DE (Alpha-2) => DEU (Alpha-3)
Convert Numeric to Alpha-3 code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(
"840 (Numeric) => " + countries.numericToAlpha3("840") + " (Alpha-3)"
);
// 840 (Numeric) => USA (Alpha-3)
Convert Alpha-3 to Numeric code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.alpha3ToNumeric("SWE"));
// 752
Convert Alpha-2 to Numeric code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.alpha2ToNumeric("SE"));
// 752
Get all Alpha-2 codes
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getAlpha2Codes());
// { 'AF': 'AFG', 'AX': 'ALA', [...], 'ZM': 'ZMB', 'ZW': 'ZWE' }
Get all Alpha-3 codes
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getAlpha3Codes());
// { 'AFG': 'AF', 'ALA': 'AX', [...], 'ZMB': 'ZM', 'ZWE': 'ZW' }
Get all Numeric codes
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(countries.getNumericCodes());
// { '004': 'AF', '008': 'AL', [...], '887': 'YE', '894': 'ZM' }
Validate country code
var countries = require("i18n-iso-countries");
// in a browser environment: countries.registerLocale(require("i18n-iso-countries/langs/en.json"));
console.log(
countries.isValid("US"),
countries.isValid("USA"),
countries.isValid("XX")
);
// true, true, false
Contribution
To add a language:
- add a json file under langs/
- add the language to the
data
object in entry-node.js at the top - add language to section Supported languages in README.md
- add language to keywords in package.json
- run
npm test
to make sure that tests are passing - open a PR on GitHub
You can check codes here: https://www.iso.org/obp/ui/#home
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].