accept-language

A tiny, dependency-free Rust library for parsing the HTTP Accept-Language header.

Library
Cargo
v3.1.0
15stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
28/100Needs Attention
Development Activity0
Maintenance20
Community20
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture72
Code Quality82
Innovation58
Learning Curve90

accept-language is a tiny Rust library for parsing and comparing the browser Accept-Language header. Given a raw header like en-US, en-GB;q=0.5, it returns the user’s languages sorted by quality preference, and its intersection helper matches those preferences against the locales your application actually supports to pick the best available language. It has no dependencies, is fuzz-tested on every change, and is designed to slot into any web server’s content-negotiation logic.

What You Get

  • A parse function that returns the header’s languages ordered by their quality (q) values
  • An intersection helper that picks the best supported language given the user’s preferences
  • A zero-dependency, fuzz-tested implementation with a documented, minimal public API

Common Use Cases

  • Deciding which translated content or locale to serve a visitor based on their browser settings
  • Adding language negotiation to a Rust web service without pulling in a heavy i18n framework
  • Normalizing and ranking language tags from incoming requests for downstream logic

Under The Hood

Architecture - The entire library lives in a single src/lib.rs of roughly 370 lines. parse tokenizes the header, extracts each language tag and its optional q weight, and returns the tags sorted by descending preference; intersection filters those parsed preferences against a caller-supplied list of supported languages to return the best matches in order. Tech Stack - It targets the Rust 2018 edition and has no runtime dependencies at all, keeping compile times and the dependency tree minimal. Code Quality - Correctness is backed by inline unit tests plus continuous fuzz testing with cargo-fuzz on every push and pull request via GitHub Actions, and there are benchmarks under benches/ to guard performance. API Design - The surface is just two free functions with obvious signatures, so integrating it is a matter of a single call in a request handler; the docs on docs.rs cover both functions with runnable examples.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search