GithubHelp home page GithubHelp logo

polarisation / iso-639-1-plus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from meikidd/iso-639-1

4.0 2.0 2.0 436 KB

ISO-639-1 codes

Home Page: https://npmjs.org/package/iso-639-1-plus

License: Other

JavaScript 100.00%

iso-639-1-plus's Introduction

ISO-639-1-plus

NPM Version Build Status Download Count

Simple interface for ISO-639-1 2-letter language codes and common IETF BCP 47 language tags.

Forked from iso-639-1 and extended with a some common language subtags for regional variations (eg. en-GB, pt-BR, zh-Hans). The intention is not to provide a definitive list, but a subset of commonly used language tags / locales.

Installation

npm install iso-639-1-plus

Usage

Node.js

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

ES Module

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

Browsers

HTML

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

Visit global variable ISO6391 in js

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

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-plus')

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:'中文'}]

iso-639-1-plus's People

Contributors

meikidd avatar polarisation avatar grossacasac avatar dependabot[bot] avatar anthony0030 avatar airglow923 avatar brianridgeway avatar andrewstoyan avatar jamesmgreene avatar klaci avatar mladimatija avatar mfedderly avatar pierreneter avatar mud avatar angaz avatar erwinleonardy avatar nickhsu avatar thomashuckert avatar vlinder avatar

Stargazers

Roland avatar Rajendra Bhochalya avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

iso-639-1-plus's Issues

The package is still broken because build was not rebuilt

https://npmfs.com/compare/iso-639-1-plus/3.0.1/3.0.2/

As you can see here the fix did not go into build/

but Node.js imports from iso-639-1-plus\build\index.js

To avoid this situation in the future I recommend:

  • Remove build/ artifact from git (to avoid polluting the commits with double changes)
  • Add a npm publish hook to build just before publish automatically (to avoid forgetting to build)
  • specify what exact files go to npm publish (src and build) (eslintrc and .vscode should not be in npm)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.