iso-639-1-da
TypeScript icon, indicating that this package has built-in type declarations

3.0.3 • Public • Published

ISO-639-1

NPM Version

Simple interface for ISO-639-1 language codes

Installation

npm install iso-639-1-da

Usage

Node.js

const ISO6391 = require('iso-639-1-da');
console.log(ISO6391.getName('en')); // 'Engelsk'

ES Module

import ISO6391 from 'iso-639-1';
console.log(ISO6391.getName('en')); // 'Engelsk'

Browsers

HTML

<script type="text/javascript" src="./node_modules/iso-639-1-da/build/index.js"></script>

Visit global variable ISO6391 in js

console.log(ISO6391.getName('en')); // 'Engelsk'

Methods

getName(code)

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

Lookup language danish name by code

getAllNames()

  • @return {array}

Get array of all language danish names

getNativeName(code)

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

Lookup language native name by code

getAllNativeNames()

  • @return {array}

Get array of all language native names

getCode(name)

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

Lookup code by danish name or native name

getAllCodes()

  • @return {array}

Get array of all codes

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

Example

const ISO6391 = require('iso-639-1')

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

console.log(ISO6391.getAllNames()) // ['Afar','Abkhasisk', ... ,'Zulu']
console.log(ISO6391.getAllNativeNames()) //['Afaraf','аҧсуа бызшәа', ... ,'isiZulu' ]

console.log(ISO6391.getCode('Kinesisk')) // 'zh'
console.log(ISO6391.getCode('中文')) // 'zh'

console.log(ISO6391.getAllCodes()) //['aa','ab',...,'zu']

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

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

Package Sidebar

Install

npm i iso-639-1-da

Weekly Downloads

5

Version

3.0.3

License

MIT

Unpacked Size

117 kB

Total Files

13

Last publish

Collaborators

  • jonasclement