JSPM

  • Created
  • Published
  • Downloads 400604
  • Score
    100M100P100Q283217F
  • License MIT

ISO-639-1 codes

Package Exports

  • iso-639-1
  • iso-639-1/build

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (iso-639-1) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ISO-639-1

Simple interface for ISO-639-1 language codes

Installation

npm install iso-639-1

Methods

getName(code)

  • @param code {string}
  • @return {string}

Lookup language english name by code

getNativeName(code)

  • @param code {string}
  • @return {string}

Lookup language native name by code

getCode(name)

  • @param name {string}
  • @return {string}

Lookup code by english name or native name

validate(code)

  • @param code {string}
  • @return {boolean}

Check whether the given code is in the list of ISO-639-1

getLanguages(codes)

  • @param codes {array}
  • @return {array}

Get the array of the language objects by the given codes

Usage

var ISO6391 = require('./iso-639-1')

console.log(ISO6391.getName('zh')) // 'Chinese'
console.log(ISO6391.getNativeName('zh')) // '中文'

console.log(ISO6391.getCode('Chinese')) // 'en'
console.log(ISO6391.getCode('中文')) // 'en'

console.log(ISO6391.validate('en')) // true
console.log(ISO6391.validate('xxx')) // false

console.log(ISO6391.getLanguages(['en', 'zh'])) 
// [{code:'en',name:'English',nativeName:'English'},{code:'zh',name:'Chinese',nativeName:'中文'}]