Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (25 sloc) 862 Bytes


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


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.


To run the test:

jasmine-node spec/
npm test


The license can be found in

Something went wrong with that request. Please try again.