Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
i18n-nationality
Advanced tools
Nationalities as adjectives mapped to Country codes. This repository is heavily based on the i18n-iso-countries repository by michaelwittig. https://github.com/michaelwittig/node-i18n-iso-countries
i18n for nationalities of ISO 3166-1 country codes. We support Alpha-2, Alpha-3 and Numeric codes from http://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements
Install it using npm: npm install i18n-nationality
var nationalities = require("i18n-nationality");
If you use i18n-nationality
with Node.js your are done. If you use the package in a browser environment you also have to register the languages you want to use to minimize file size.
// Support german & english languages.
nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
nationalities.registerLocale(require("i18n-nationality/langs/de.json"));
var nationalities = require("i18n-nationality");
// in a browser environment: countries.registerLocale(require("i18n-nationality/langs/en.json"));
console.log("US (Alpha-2) => " + nationalities.getName("US", "en")); // American
console.log("US (Alpha-2) => " + nationalities.getName("US", "de")); // Amerikanisch
console.log("USA (Alpha-3) => " + nationalities.getName("USA", "en")); // American
console.log("USA (Numeric) => " + nationalities.getName("840", "en")); // American
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.getNames("en")); // { 'AF': 'Afghan', 'AL': 'Albanian', [...], 'ZM': 'Zambian', 'ZW': 'Zimbabwean' }
de
: Germanen
: Englishvar nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log("American => " + nationalities.getAlpha2Code('American', 'en'));
// American => US
console.log("American => " + nationalities.getAlpha3Code('American', 'en'));
// American => USA
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log("USA (Alpha-3) => " + nationalities.alpha3ToAlpha2("USA") + " (Alpha-2)");
// USA (Alpha-3) => US (Alpha-2)
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log("840 (Numeric) => " + nationalities.numericToAlpha2("840") + " (Alpha-2)");
// 840 (Numeric) => US (Alpha-2)
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log("DE (Alpha-2) => " + nationalities.alpha2ToAlpha3("DE") + " (Alpha-3)");
// DE (Alpha-2) => DEU (Alpha-3)
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log("840 (Numeric) => " + nationalities.numericToAlpha3("840") + " (Alpha-3)");
// 840 (Numeric) => USA (Alpha-3)
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.alpha3ToNumeric("SWE"));
// 752
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.alpha2ToNumeric("SE"));
// 752
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.getAlpha2Codes());
// { 'AF': 'AFG', 'AX': 'ALA', [...], 'ZM': 'ZMB', 'ZW': 'ZWE' }
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.getAlpha3Codes());
// { 'AFG': 'AF', 'ALA': 'AX', [...], 'ZMB': 'ZM', 'ZWE': 'ZW' }
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.getNumericCodes());
// { '004': 'AF', '008': 'AL', [...], '887': 'YE', '894': 'ZM' }
var nationalities = require("i18n-nationality");
// in a browser environment: nationalities.registerLocale(require("i18n-nationality/langs/en.json"));
console.log(nationalities.isValid("US"), nationalities.isValid("USA"), nationalities.isValid("XX")));
// true, true, false
To add a language:
data
object in enty-node.js at the topnpm install && make test
to make sure that tests are passingYou can check codes here: https://www.iso.org/obp/ui/#home
FAQs
i18n for nationality
The npm package i18n-nationality receives a total of 6,623 weekly downloads. As such, i18n-nationality popularity was classified as popular.
We found that i18n-nationality demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.