Translated lists of countries and languages in JSON format
Find a file
Wille Marcel 22a2e5d8aa
Merge pull request #4 from chkob/thai-translation
to be more properly translation to Thai language of country\territory…
2020-07-23 11:54:54 -03:00
esdoc First commit 2016-11-09 11:48:48 +01:00
lib disable languages not required by our build + fix pt and es translations 2020-04-03 07:16:52 -03:00
res to be more properly translation to Thai language of country\territory names 2020-06-21 18:42:25 +07:00
scripts Updated nl files 2019-06-26 10:22:19 +02:00
src disable languages not required by our build + fix pt and es translations 2020-04-03 07:16:52 -03:00
test First commit 2016-11-09 11:48:48 +01:00
.esdoc First commit 2016-11-09 11:48:48 +01:00
.gitignore Updated nl files 2019-06-26 10:22:19 +02:00
package.json disable languages not required by our build + fix pt and es translations 2020-04-03 07:16:52 -03:00
README.md Added minimization 2019-02-01 22:51:59 +01:00
webpack.config.js Fix target node in build 2019-02-06 22:40:34 +01:00
yarn.lock disable languages not required by our build + fix pt and es translations 2020-04-03 07:16:52 -03:00

 Code documentation

iso-countries-languages

This library provides the full list of ISO 639-1 languages and the full list of ISO 3166-1 countries. The library supports 89 languages (the full list is available by querying the library API itself) and it is designed to be easy to import and use.

How to install and use#

Simply run the following code and look at the examples to see typical usages:

npm install iso-countries-languages

Code documentation

Code documentation

API list

getSupportedLangs

Returns the list of supported languages.

var isoCountriesLanguages = require('iso-countries-languages');

var supportedLangs = isoCountriesLanguages.getSupportedLangs();
console.log("Supported languages: ");
console.log(supportedLangs);

Output

Supported languages: 
[ 'af',
  'am',
  'ar',
  'az',
  'ba',
  
  ...
  
  'udm',
  'uk',
  'ur',
  'uz',
  'vi',
  'xh',
  'yi',
  'zh' ]

getCountries

Returns the ISO 3166-1 list of countries translated in the language passed as a parameter.

var isoCountriesLanguages = require('iso-countries-languages');

var countriesInFrench = isoCountriesLanguages.getCountries('fr');
console.log("Countries in french: ");
console.log(countriesInFrench);

Output

Countries in french: 
{ AF: 'Afghanistan',
  AX: 'Les Îles D\'Åland',
  AL: 'L\'albanie',
  DZ: 'L\'algérie',
  AS: 'Samoa Américaines',
  AD: 'Andorre',
  
  ...

  WF: 'Wallis-et-Futuna',
  EH: 'Sahara Occidental',
  YE: 'Yémen',
  ZM: 'La zambie',
  ZW: 'Zimbabwe' }

getCountry

Returns the translation for the country code passed as a parameter in the language passed as a parameter.

var isoCountriesLanguages = require('iso-countries-languages');

var italyInFrench = isoCountriesLanguages.getCountry('fr', 'IT');
console.log("Italy in french: ");
console.log(italyInFrench);

Output

Italy in french: 
Italie

getLanguages

Returns the ISO 639-1 list of languages translated in the language passed as a parameter

var isoCountriesLanguages = require('iso-countries-languages');

var languagesInItalian = isoCountriesLanguages.getLanguages('it');
console.log("Languages in italian: ");
console.log(languagesInItalian);

Output

Languages in italian: 
{ ab: 'Di abcasia',
  aa: 'Lontano',
  af: 'Afrikaans',
  ak: 'Akan',
  sq: 'Albanese',
  am: 'Amarico',
  ar: 'Arabo',
   
  ...

  xh: 'Xhosa',
  yi: 'Yiddish',
  yo: 'Yoruba',
  za: 'Zhuang, Chuang',
  zu: 'Zulu' }

getLanguage

Returns the translation for the language code passed as a parameter in the language passed as a parameter

var isoCountriesLanguages = require('iso-countries-languages');

var spanishInItalian = isoCountriesLanguages.getLanguage('it', 'es');
console.log("Spanish in italian: ");
console.log(spanishInItalian);

Output

Spanish in italian: 
Spagnolo