Socket
Socket
Sign inDemoInstall

accept-language

Package Overview
Dependencies
0
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    accept-language

HTTP Accept-Language parser for node


Version published
Weekly downloads
138K
decreased by-15.22%
Maintainers
1
Install size
24.4 kB
Created
Weekly downloads
 

Readme

Source

accept-language Build Status

NPM

accept-language parses HTTP Accept-Language header and returns the most likely language tag or a consumable array of language tags.

Installation:

npm install accept-language --save

Usage:

var acceptLanguage = require('accept-language');
accepLanguage.languageTags(['en-US', 'zh-CN']);
console.log(accepLanguage.get('en-GB,en;q=0.8,sv'));
// outputs: 'en-US'

var language = acceptLanguage.parse('en-GB,en;q=0.8,sv');
console.log(language);

/*
[
  {
    value: 'en-US',
    language: "en",
    region: "US",
    quality: 1.0
  }
];
*/

L10ns is internationalization workflow and formatting tool. This library was specifically built for L10ns.

API

accepLanguage.languageTags(Array languageTags);

Define your language tags in highest priority comes first. The language tags must comply with BCP47 standard. I.e. all language tags en, en-US and zh-Hant-TW are working.

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

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

acceptLanguage.get('en-GB,en;q=0.8,sv'));
accepLanguage.parse(String acceptLanguageString);

Parse an Accept-Language string and get a consumable array. In order for it to work you must set all your language tags first.

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

License

MIT

Keywords

FAQs

Last updated on 14 Feb 2015

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