gitwtfhub

wtf is http_accept_language?

kriechi/http_accept_language — explained in plain English

Analysis updated 2026-08-07 · repo last pushed 2015-01-26

RubyAudience · developerComplexity · 2/5DormantSetup · easy

TL;DR

A Ruby gem that reads the language preference a visitor's browser sends and gives your Rails app a sorted list of languages to match against, with flexible regional fallback.

Mindmap

mindmap
  root((repo))
    What it does
      Reads browser language
      Returns sorted list
      Matches regional variants
    Tech stack
      Ruby
      Rails
    Use cases
      Multilingual websites
      Auto locale switching
      Closest match fallback
    Audience
      Rails developers
      Multilingual teams
    Flexibility
      Strict regional matching
      Base language matching
      Auto locale feature

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Automatically serve a visitor the closest matching language your app supports.

REASON 2

Switch your entire Rails app translations automatically based on the visitor's browser preference.

REASON 3

Match browser language requests to available locales using flexible or strict regional rules.

What's in the stack?

RubyRuby on Rails

How it stacks up

kriechi/http_accept_language0xdevalias/huginn-chef100rabhg/masterdetailapp
LanguageRubyRubyRuby
Last pushed2015-01-262014-09-302024-02-20
MaintenanceDormantDormantDormant
Setup difficultyeasyhardmoderate
Complexity2/54/52/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Wtf does this do

The http_accept_language gem helps Ruby on Rails apps detect what language a visitor prefers, based on a signal their browser sends automatically. When someone arrives at your site, their browser includes a hidden preference like "I prefer Dutch, but English is fine too." This tool reads that signal and hands your app a clean list of languages to work with. Under the hood, it intercepts incoming web requests and parses the language header into a sorted array of preferences. It also applies a practical twist on the standard rules: if someone requests "en-US" (US English) but your app only offers "en" (generic English), the gem treats them as compatible. The strict specification says that shouldn't work in that direction, but real-world usage calls for it. This is useful for anyone building a multilingual website. Say you have a store available in English, US English, and Belgian Dutch. A visitor from the Netherlands whose browser lists Dutch as their top choice would automatically get served Belgian Dutch, the closest match you offer. Another visitor who prefers British English but only finds US English available gets that instead. You can also flip on an "auto locale" feature that wires this up so your entire app switches translations on its own. Developers can pick from a few methods depending on how strict they want the matching to be. Some look for exact regional matches, while others ignore region entirely and just match on the base language. The README doesn't go into detail about performance characteristics or advanced configuration, but the tool covers the common scenarios most teams face when deciding which language to show a new visitor.

Yoink these prompts

Prompt 1
Install the http_accept_language gem in my Rails app and set it up so visitors automatically see the best-matching language based on their browser preference.
Prompt 2
Show me how to use http_accept_language to detect the visitor's preferred language and serve Belgian Dutch when they request generic Dutch but I only offer nl-BE.
Prompt 3
Help me configure http_accept_language to use the auto-locale feature so my Rails app switches translations without manual user selection.
Prompt 4
Compare the available matching methods in http_accept_language and tell me which one to use if I want to ignore regional variants and match on base language only.

Frequently asked questions

wtf is http_accept_language?

A Ruby gem that reads the language preference a visitor's browser sends and gives your Rails app a sorted list of languages to match against, with flexible regional fallback.

What language is http_accept_language written in?

Mainly Ruby. The stack also includes Ruby, Ruby on Rails.

Is http_accept_language actively maintained?

Dormant — no commits in 2+ years (last push 2015-01-26).

How hard is http_accept_language to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is http_accept_language for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.