acc-lang-parser

A simple parser for http Accept-Language headers.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
14Aug 28, 2012Aug 27, 2012Minified + gzip package size for acc-lang-parser in KB

Readme

acc-lang-parser

A simple parser for http Accept-Language Headers in nodejs.

usage

To only get the first language of the header:

var accLangParser = require("parse-acc-lang");
var result = accLangParser.extractFirstLang("de-DE");

result => {language: "de", locale: "DE"}

To get a list of all languages:

var accLangParser = require("parse-acc-lang");
var result = accLangParser.extractAllLangs("de-DE, en-GB");

result => [{language: "de", locale: "DE"}
          ,{language: "en", locale: "GB"}]

Take a look into the specs for more details about invalid handlers.

Use accLangParser.extractFirstLang if you only interested in the first language range, because this function will skip on parsing the other ranges.

testing

To run the test:

jasmine-node spec/
or
npm test

license

The license can be found in license.md.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.