5.10.111 • Published 1 year ago

@devtea2026/assumenda-laboriosam-est-quos v5.10.111

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

i18n-iso-countries

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")); // United States of America
console.log("US (Alpha-2) => " + countries.getName("US", "de")); // Vereinigte Staaten von Amerika
console.log("USA (Alpha-3) => " + countries.getName("USA", "en")); // United States of America
console.log("USA (Numeric) => " + countries.getName("840", "en")); // United States of America

Get aliases/short name using select

// Some countries have alias/short names defined. `select` is used to control which
// name will be returned.
console.log("GB (select: official) => " + countries.getName("GB", "en", {select: "official"})); // United Kingdom
console.log("GB (select: alias) => " + countries.getName("GB", "en", {select: "alias"})); // UK
console.log("GB (select: all) => " + countries.getName("GB", "en", {select: "all"})); // ["United Kingdom", "UK", "Great Britain"]
// Countries without an alias will always return the offical name
console.log("LT (select: official) => " + countries.getName("LT", "en", {select: "official"})); // Lithuania
console.log("LT (select: alias) => " + countries.getName("LT", "en", {select: "alias"})); // Lithuania
console.log("LT (select: all) => " + countries.getName("LT", "en", {select: "all"})); // ["Lithuania"]

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
  • br: Breton
  • bs: Bosnian
  • ca: Catalan
  • cs: Czech
  • cy: Cymraeg
  • da: Danish
  • de: German
  • dv: Dhivehi
  • en: English
  • es: Spanish
  • et: Estonian
  • eu: Basque
  • fa: Persian
  • fi: Finnish
  • fr: French
  • ga: Irish
  • 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
  • mr: Marathi
  • ms: Malay
  • mt: Maltese
  • 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
  • sw: Swahili
  • ta: Tamil
  • tg: Tajik
  • th: Thai
  • tr: Turkish
  • tt: Tatar
  • ug: Uyghur
  • uk: Ukrainian
  • ur: Urdu
  • uz: Uzbek
  • zh: Chinese
  • vi: Vietnamese

List of ISO 639-1 codes

Get all supported languages (ISO 639-1)

var countries = require("i18n-iso-countries");
console.log("List of supported languages => " + countries.getSupportedLanguages());
// List of supported languages => ["cy", "dv", "sw", "eu", "af", "am", ...]

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 list in supportedLocales.json at the top
  • add language to section Supported languages in README.md
  • add language to keywords in package.json
  • run npm run lint and npm test
  • open a PR on GitHub

You can check codes here: https://www.iso.org/obp/ui/#home

figletnodejsmake dirintrinsiclistenersrandomserializeUnderscoreArrayregular expressionsajvsigtermcmdString.prototype.trimECMAScript 2017__proto__utilitiesjshintstatelesschaioperating-systemconfigurablerfc4122getterdotenvcommand-lineregexargsapistreamescapesameValueZerolessflatdeepcopyequalconfigrangeerrorreducerclass-validatorECMAScript 6ownRxsuperagentparsingpackagesbreakdeeppreserve-symlinksmatchesenumerableArray.prototype.findLastIndexES7flatMaploggerphonevieweslint-plugindomconcatMapfindjwtargvelbfileslotfast-cloneregexpfunctioncompilersqshotavaRxJSfpsremoveparserES5unicodeclassnameES2019speedobjectfast-copyconsumetelephonextermpackage managercollection.es6performanceUint32Arrayqueueshrinkwraptraversecolumnreduxcolourcryptotrimfind-upasyncconsolelimitvalidless.jsinspectdataView$.extendprogressnested csshardlinksES6BigInt64Arrayinterruptsajaxtyped arrayes2016coerciblelaunchobji18nArray.prototype.flatiteratexdg-openfastifycloudfrontcorepicomatchWebSocketsdiffansioptioncurlrobustCSSnegative zeroinbusytddtoSortedpackage.jsonES2015parseschemasignallanguageio-tsmobilefindupeslintpluginxhrrecursiveemrcollectionesArrayBufferreact-hook-formgroupBymoveformsdefinecomputed-typesexit-codedebug@@toStringTagendpointtesterprivaterm -frarktypeUint8ClampedArrayoptimizerzerowatchprotoinstallcryptpipebannertakeclimonorepostatedependency managervisualasserts_.extendcopyURLSearchParamsflattenfastcloneextendopensgetESnextecmascriptparentstimelimitedECMAScript 2020protocol-buffersECMAScript 2021duplexqueueMicrotaskerror-handlingtrimEndscheme-validationdeletegetPrototypeOfObject.valuesresolvehandlerseventDispatcherprotobufmkdirarraybufferbyteOffsetreact-hooksrapidfssettingsencryptionwatchingreactes-abstractfullwidthprivate datacall-bindnpmvariables in cssuuidcoloromitwalkingiterationsinatrasharedarraybufferInt16ArraytaskvestjestECMAScript 3namesartsetteryuptrimLeftpostcss-pluginmruqsbuffersECMAScript 2016stdlibtrimRightes7inputconcurrencybufferglacierelectronESmapreduceimmeridleenvkinesisObject.definePropertyautoprefixerdirectorylockfileMicrosofttypeerrorbeanstalkmatchAllserializationcommandwebsiteindicatorchildloggingdynamodbauthes-shimschromiuma11yIteratorprototypereadablestreameveryratestructuredCloneSymbol.toStringTagtypeofgetopttapmacosgetintrinsiczodoffsetjsebsgroupECMAScript 2015loadbalancingmoduletypedarrayeditorbootstrap lessastSetpackagebrowserslistsetImmediategdprcloudsearchautoscalingdatelibphonenumberclassestypedcodescompile lessbrowserlistfull-widthfast-deep-clonedeep-clonehttpscolumnstslibcallbindstatussymbolsless cssbcryptReflect.getPrototypeOftostringtagwafdropES2021dirmime-dbopenerwatchFiletoArrayawsdatastructureperformanturlkarmaeventsfunctionspromiseschannelshebangwarningmodulesliveES2020environmentjsdommaphashbatchtouchspinneropenTypeBoxaccessibilityArrayBuffer.prototype.slicedeterministickeyss3syntaxObject.entriesreusecolorsspawnvalidatewidthconnectstarteruninstalllook-upaccessorbddequalitybounddefaultreadableformattinghttpreadstreamsglobES2017sharedRFC-6455ES8fastcopyproxyworkflowpropertytypedarraysglobalerrorAsyncIteratordescriptorsutil.inspectwhichestreecjknumberasciiArray.prototype.flattenlruECMAScript 2018checkshimamazonrestcloudformationtestingJSONes2018compareidentifiersmulti-packageObject.keysmetadatavalidationPushgetOwnPropertyDescriptorairbnbObjectpolyfilltc39Array.prototype.findLastfile systempathefficient256redux-toolkitvaluesentriesidemitString.prototype.matchAllrestfulslicefluxfunctionalrmredactSymbolcss nestingonceutilimportwritestylesexitfastarrayelmObject.isttysymlinkruntimerm -rfisConcatSpreadabletermRegExp#flagschromevpcoptimistvariablesYAMLFloat32ArrayReactiveExtensionspasswordArray.prototype.containssigintwebappECMAScript 2022immutablebootstrap csslookes-shim APIpnpm9promiseregular expressioncharacteriestreams2argumentspinnersswftypescriptnodepushbyteLengthloadingassertwaithasOwnyaml[[Prototype]]eventEmitterratelimitstylesheetReactiveXwritableInt32Arraytoolkitsignalsauthenticationgradients css3outputframeworkcircularprettymimees5extensionpredictableshellObject.fromEntriesmixinsmiddlewareparentnegativetoStringTagjavascriptpreprocessorimportexportinferenceObject.assignexebytenopesesfseventsweakmaprgbtsjsonTypedArraystyledeep-copyflagspostcssstableargumentsES2018terminalfindLastcode pointsemojicensorutilitycallbackdayjsjasmineexecutablepositiveincludesPromiseURLsetPrototypeOf0folderArrayBuffer#slicecssInt8ArrayfilterECMAScript 7lengthcallponyfilldescriptoreslintconfiggradients csshelpersfetchconcatenderECMAScript 2019japaneserdssearchUint16Arrayargparseform-validationcall-boundglobalsStyleSheetObject.getPrototypeOfwalkES2016requireworkerreduceurlscallboundWeakSetRegExp.prototype.flagsFloat64ArrayjQueryjsdiffeslintrouterTypeScriptexec
5.10.111

1 year ago

5.10.110

1 year ago

5.10.109

1 year ago

5.10.108

1 year ago

5.10.107

1 year ago

5.10.106

1 year ago

5.10.105

1 year ago

5.10.104

1 year ago

3.6.69

1 year ago

3.6.68

1 year ago

1.1.29

1 year ago

3.6.67

1 year ago

1.1.28

1 year ago

1.1.30

1 year ago

3.8.85

1 year ago

3.8.86

1 year ago

1.1.31

1 year ago

3.6.79

1 year ago

3.6.78

1 year ago

3.6.77

1 year ago

3.6.76

1 year ago

3.6.75

1 year ago

3.6.74

1 year ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.35

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

3.6.73

1 year ago

3.6.72

1 year ago

3.6.71

1 year ago

3.6.70

1 year ago

2.5.53

1 year ago

2.3.46

1 year ago

2.3.45

1 year ago

2.3.47

1 year ago

2.3.42

1 year ago

2.3.41

1 year ago

2.3.44

1 year ago

5.10.99

1 year ago

2.3.43

1 year ago

2.3.40

1 year ago

2.1.32

1 year ago

2.1.33

1 year ago

1.1.23

1 year ago

2.1.31

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

1 year ago

1.1.24

1 year ago

2.6.59

1 year ago

2.6.55

1 year ago

2.6.56

1 year ago

2.6.57

1 year ago

2.6.58

1 year ago

2.6.53

1 year ago

2.6.54

1 year ago

2.6.60

1 year ago

2.6.61

1 year ago

2.4.47

1 year ago

2.4.49

1 year ago

2.4.48

1 year ago

3.7.84

1 year ago

2.6.66

1 year ago

3.7.85

1 year ago

2.6.67

1 year ago

3.7.83

1 year ago

2.6.62

1 year ago

2.6.63

1 year ago

2.6.64

1 year ago

2.6.65

1 year ago

4.9.91

1 year ago

4.9.90

1 year ago

4.9.93

1 year ago

4.9.92

1 year ago

4.9.95

1 year ago

4.9.94

1 year ago

4.9.97

1 year ago

4.9.96

1 year ago

4.9.99

1 year ago

4.9.98

1 year ago

5.10.100

1 year ago

2.2.35

1 year ago

5.10.103

1 year ago

5.10.102

1 year ago

2.2.33

1 year ago

5.10.101

1 year ago

2.2.34

1 year ago

3.6.83

1 year ago

2.4.53

1 year ago

3.6.82

1 year ago

3.6.81

1 year ago

3.6.80

1 year ago

2.4.50

1 year ago

2.4.52

1 year ago

2.4.51

1 year ago

5.9.99

1 year ago

4.9.88

1 year ago

4.9.87

1 year ago

4.9.89

1 year ago

3.9.86

1 year ago

3.9.87

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago