liveBook · Manning

Accept-Language

As explained in The Design of Web APIs, Second Edition

Accept-Language is an HTTP request header that communicates the languages and language variants preferred by a client.

Accept-Language is an HTTP request header that communicates a client’s preferred languages and language variants. APIs can use it to translate human-facing values or error messages while keeping machine-facing properties and codes stable. section 9.7.2 section 9.8.3

Localized transaction categories

A request such as GET /accounts/123/transactions with Accept-Language: fr can return Agence de voyage for a human-readable category label. Accept-Language: fr-CA selects a regional variant, while fr;q=0.9, it;q=0.8, *;q=0.5 expresses language preferences and fallback. English may serve as the default when no preference is supplied. section 9.7.2

Apply the header with these boundaries:

  • Translate labels, messages, and other human-facing values; do not translate property names or machine-readable codes. section 9.7.2
  • Use the preference for localized error messages and, when necessary, string formatting such as amounts in a PDF response. section 9.7.2 section 9.8.3

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains defaults, regional variants, q weights, translation boundaries, and locale-dependent formatting, while noting unsupported languages without detailing handling.
Examples
Uses transaction category labels, French and English responses, regional language variants, weighted preferences, PDF amounts, and localized validation errors.
What you can do after
Apply it via HTTP content negotiation to localize human-facing values and error messages without destabilizing application-facing names or codes.
How it connects
Connects language negotiation with locale adaptation, content negotiation, human-readable error feedback, and machine-readable API data.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.