dns-witch.net.eu.org/node_modules/iso-639-1
2025-07-05 18:19:59 +02:00
..
.vscode 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
build 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
src 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
test 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.eslintrc 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.eslintrc 2 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.nvmrc 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.nvmrc 2 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.prettierrc 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.prettierrc 2 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.travis 2.yml 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
.travis.yml 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
CHANGELOG 2.md 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
CHANGELOG.md 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
index.d 2.ts 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
index.d.ts 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
LICENSE 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
LICENSE 2 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
package 2.json 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
package.json 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
readme 2.md 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
readme.md 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
webpack.config 2.js 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00
webpack.config.js 11ty + RIP DNS Witch EU.ORG service 2025-07-05 18:19:59 +02:00

ISO-639-1

NPM Version Build Status Download Count

Simple interface for ISO-639-1 language codes

Installation

npm install iso-639-1

Usage

Node.js

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

ES Module

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

Browsers

HTML

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

Visit global variable ISO6391 in js

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

Methods

getName(code)

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

Lookup language english name by code

getAllNames()

  • @return {array}

Get array of all language english 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 english 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')) // 'Chinese'
console.log(ISO6391.getNativeName('zh')) // '中文'

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

console.log(ISO6391.getCode('Chinese')) // '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:'English',nativeName:'English'},{code:'zh',name:'Chinese',nativeName:'中文'}]