@dptole/al-api

0.4.0 • Public • Published

Accept-Language extra info API

Build status Issue status NPM Version Downloads Say thanks

API for reading extra information from the HTTP header Accept-Language based on the Language subtag registry file.

Details for the Accept-Language HTTP header can be found at the Tags for Identifying Languages, which refers to the Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content.

Examples

const al_api = require('@dptole/al-api')

al_api.getLanguageDescriptionBySubtag('en') // ['English']
al_api.getRegionDescriptionBySubtag('US') // ['United States']

al_api.getAcceptLanguageInfo('pt,pt-BR;q=0.9,es-VE;q=0.8')
/*
  [{
    'language': {
      'subtag': 'pt',
      'info': ['Portuguese']
    }
  }, {
    'language': {
      'subtag': 'pt',
      'info': ['Portuguese']
    },
    'region': {
      'subtag': 'BR',
      'info': ['Brazil']
    }
  }, {
    'language': {
      'subtag': 'es',
      'info': ['Castilian']
    },
    'region': {
      'subtag': 'VE',
      'info': ['Venezuela']
    }
  }]
*/

License

MIT

Package Sidebar

Install

npm i @dptole/al-api

Weekly Downloads

0

Version

0.4.0

License

MIT

Last publish

Collaborators

  • dptole