{"id":18085,"library":"acc-lang-parser","title":"acc-lang-parser","description":"A simple parser for HTTP Accept-Language headers in Node.js. Version 1.0.4 (last released in 2016) extracts the first language or all language ranges from a header string. Returns objects with 'language' and 'locale' fields. Unlike more modern alternatives like 'accept-language-parser', this package has limited features, no TypeScript support, and is unmaintained. It was originally published under the npm name 'parse-acc-lang' (now deprecated) and later republished as 'acc-lang-parser'.","status":"maintenance","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/adcloud/acc-lang-parser","tags":["javascript","http","accept-language","parser","nodejs"],"install":[{"cmd":"npm install acc-lang-parser","lang":"bash","label":"npm"},{"cmd":"yarn add acc-lang-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add acc-lang-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only, does not support ESM imports. The npm package name is 'acc-lang-parser' but the require path string is 'parse-acc-lang' (the old name).","wrong":"import parser from 'parse-acc-lang';","symbol":"parse-acc-lang","correct":"const parser = require('parse-acc-lang');"},{"note":"Returns a single object with language and locale, or null if invalid input.","symbol":"extractFirstLang","correct":"const result = parser.extractFirstLang('de-DE');"},{"note":"Returns an array of objects. No options parameter is supported.","wrong":"const results = parser.extractAllLangs('de-DE, en-GB', { strict: true });","symbol":"extractAllLangs","correct":"const results = parser.extractAllLangs('de-DE, en-GB');"}],"quickstart":{"code":"const parser = require('parse-acc-lang');\nconst header = 'de-DE, en-GB;q=0.9, fr;q=0.8';\nconst first = parser.extractFirstLang(header);\nconsole.log(first); // { language: 'de', locale: 'DE' }\nconst all = parser.extractAllLangs(header);\nconsole.log(all);\n// [\n//   { language: 'de', locale: 'DE' },\n//   { language: 'en', locale: 'GB' },\n//   { language: 'fr', locale: '' }\n// ]","lang":"javascript","description":"Parses an Accept-Language header to get the first language and all languages."},"warnings":[{"fix":"Use require('parse-acc-lang') in code, not require('acc-lang-parser').","message":"Package name mismatch: npm package is 'acc-lang-parser' but require path uses 'parse-acc-lang'.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Create your own .d.ts file or use a modern alternative with TypeScript support.","message":"No TypeScript definitions available.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Check for empty locale string before use.","message":"If extracted language tag has no locale (e.g., 'fr'), the locale field is an empty string ''.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a more complete parser like 'accept-language-parser' if you need quality weighting.","message":"Quality values (q=) are ignored; the parser does not sort by weight.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use require('parse-acc-lang') in your code, even though the npm package name is 'acc-lang-parser'.","cause":"Using require('acc-lang-parser') instead of require('parse-acc-lang').","error":"Error: Cannot find module 'parse-acc-lang'"},{"fix":"Ensure you require('parse-acc-lang') and that the module exports the correct functions.","cause":"Incorrect import path or using a different package version.","error":"TypeError: parser.extractFirstLang is not a function"},{"fix":"Pass a valid Accept-Language header string. For null/undefined, manually handle or return a default.","cause":"Input header is null, undefined, or an empty string.","error":"Expected an object but got undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}