npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hotosm/iso-countries-languages

v1.1.2

Published

ISO 639-1 languages and ISO 3166-1 countries translated in the languages required by Tasking Manager

Downloads

1,701

Readme

iso-countries-languages

npm version

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.

Installation

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

yarn add @hotosm/iso-countries-languages

Customization

This library includes data for more than 150 languages. To make the build smaller, we have only 24 languages enabled, but you can easily build that package with more languages enabled. Follow those steps:

To update the countries data from OpenStreetMap, execute yarn update-countries.

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

License

MIT License

The country names included in this project came from OpenStreetMap. The data is made available under ODbL.