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

langs-es

v4.0.2

Published

ISO 639-1/2/3 Language codes with English and local names

Downloads

29

Readme

Langs-es

Published version MIT Licensed

This library provides ISO 639-1/2/3 language codes with English and local names.

Forked from langs.

Installation

$ npm i langs-es

What's with all the ISO version numbers?

ISO 639 is broken up into many different parts, each either defining language codes or defining standards for codes in later versions. The ones included in this library are:

  • ISO 639-1 2 characters, one per language or ISO 639 macrolanguage
  • ISO 639-2/2T 3 characters, one per language
  • ISO 639-2B 3 characters, mostly the same as 639-2T but with some derived from their English name rather than local name
  • ISO 639-3 3 characters, mostly the same as 639-2T but using the canonical ISO 639 macrolanguage code

The macrolanguages described above cover cases where a language is considered to be a dialect of another in some standards but not in others, e.g Standard Arabic arb and Arabic ara. There's more information on the Wikipedia page.

Usage

import langs from 'langs-es';
/* -or- */
/* const langs = require('langs-es'); */

langs.all();
// [
//     { name: 'English', local: 'English', '1': 'en', '2': 'eng', 2T: 'eng', 2B: 'eng',
//       '3': 'eng', invertedName: 'English', refName: 'English', scope: 'I', type: 'L' },
//     { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//       '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' },
//     ...
// ]

langs.names();
// [
//     'English',
//     'Korean',
//     ...
// ]

langs.names(true);
// [
//     'English',
//     '한국어',
//     ...
// ]

langs.codes('1');
// [
//     'en',
//     'ko',
//     ...
// ]

langs.codes('2T' /*same as '2'*/);
// [
//     'eng',
//     'kor',
//     ...
// ]

langs.codes('2B');
// [
//     'eng',
//     'kor',
//     ...
// ]

langs.codes('3');
// [
//     'eng',
//     'kor',
//     ...
// ]

langs.where('name', 'Korean');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.where('local', '한국어, 조선어');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.where('1', 'ko');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.where('2', 'kor');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.where('2T', 'kor');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.where('2B', 'kor');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.where('3', 'kor');
// { name: 'Korean', local: '한국어', '1': 'ko', '2': 'kor', 2T: 'kor', 2B: 'kor',
//   '3': 'kor', invertedName: 'Korean', refName: 'Korean', scope: 'I', type: 'L' }

langs.has('name', 'Korean');
// true

langs.has('local', '한국어, 조선어');
// true

langs.has('1', 'ko');
// true

langs.has('2', 'kor');
// true

langs.has('2T', 'kor');
// true

langs.has('2B', 'kor');
// true

langs.has('3', 'kor');
// true

langs.has('name', 'Geordie');
// false

langs.has('high', 'fives');
// false

Contributing

Contributions are welcome via pull request on github. Please run unit tests and linter locally prior to submitting your pull request.

git clone [email protected]:zxanderh/langs-es.git
cd ./langs-es
npm i
# make your changes
npm lint
npm run build
npm test

Generating src/data.ts

The file containing all of the language code data is automatically generated using tables downloaded from the official ISO-639-3 website. These tables do not change often, but when they do, a new data file can be generated with npm run generate.

By default, the generator will save the tables to be reused in future runs. To force the generator to download fresh copies of the tables, use npm run generate --- --fetch.

License

The content of this library is released under the MIT License by Zane Huston (forked from package by Andrew Lawson).
You can find a copy of this license in LICENSE or at http://www.opensource.org/licenses/mit.