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 lets clients express preferred languages for human-facing API data and error messages. APIs can make it optional and use a default such as English. section 9.7.2

When adapting responses, keep consumer applications’ machine-readable inputs stable:

  • Translate human-facing labels, but not property names or codes that consuming applications use. section 9.7.2
  • Support language variants such as fr-FR and fr-CA; q-values let clients rank preferences and indicate acceptable fallbacks. section 9.7.2
  • Use the preferred language for informative error messages. APIs usually leave string formatting to consumers, though an API returning a PDF may format amounts itself. section 9.7.2 section 9.8.3

Requesting transaction labels

A client can send Accept-Language: fr to receive a French label such as “Agence de voyage” while the category code remains travel_agency. Accept-Language: fr;q=0.9, it;q=0.8, *;q=0.5 prefers French, then Italian, and accepts any language otherwise. section 9.7.2

How The Design of Web APIs, Second Edition covers it

How deep it goes
Defines optional negotiation, language variants, q-value priorities, stable machine-readable values, and a PDF-formatting exception.
Examples
Uses transaction labels, French and English variants, weighted language preferences, PDF amounts, and localized error messages.
What you can do after
Apply it via the Accept-Language header to request localized human-facing values while keeping property names and codes stable.
How it connects
Connects HTTP content negotiation with locale adaptation, machine-readable codes, and informative API error feedback.

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.