Socket
Socket
Sign inDemoInstall

accept-language

Package Overview
Dependencies
2
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    accept-language

Accept-Language parser for nodejs


Version published
Weekly downloads
149K
decreased by-20.08%
Maintainers
1
Install size
37.5 kB
Created
Weekly downloads
 

Readme

Source

accept-language Build Status

NPM

accept-language parses HTTP Accept-Language header and returns a matched defined language.

Installation:

npm install accept-language --save

Usage:

// var acceptLanguage = require('accept-language');
import acceptLanguage from 'accept-language';
acceptLanguage.languages(['en-US', 'zh-CN']);
console.log(acceptLanguage.get('en-GB,en;q=0.8,sv'));
/*

'en-US'

*/

Usage with Express:

If you are using Express server please use the middleware express-request-language.

API

acceptLanguage.languages(Array languageTags);

Define your language tags ordered in highest priority comes first fashion. The language tags must comply with BCP47 standard.

acceptLanguage.languages(['en-US', 'zh-CN']);
acceptLanguage.get(String acceptLanguageString);

Get the most likely language given an Accept-Language string. In order for it to work you must set all your languages first.

acceptLanguage.get('en-GB,en;q=0.8,sv');

Maintainer

Tingan Ho @tingan87

License

MIT

Keywords

FAQs

Last updated on 21 Oct 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc