Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> There’s the Q factor in the Accept-Language header that allows you to indicate your preference for the quality level of the translation.

???

The q factor is just for ordering the language preferences from top to bottom (i.e. it doesn't matter whether I write "de,en;q=0.8" or "en;q=0.8,de" because both of them mean that I prefer German over English because German is implicitly q=1.0 and en is explicitly only q=0.8) and doesn't say anything about the quality of the content.



They're called quality values because they're intended to negotiate the tradeoff between different ways to serve the same content in different formats of varying quality, e.g. highly compressed JPEG with artifacts vs lossless PNG.

Applying this to Accept-Language, "de,en;q=0.8" means "I prefer German content unless it's less than 80% as good as the English alternative."

Of course in practice servers tend to treat all content they have as quality 1 and all content they don't have as quality 0 and then the lovingly crafted fractional quality values collapse to a simple ordered list. ("We serve what we have and you eat what you get.")


I had to check the standard [0] on this and there seems to be some ambiguity, maybe simply with usage vs intent. The MDN entry states it is simply priority or preference [1]

"12.4.2. Quality Values

The content negotiation fields defined by this specification use a common parameter, named "q" (case-insensitive), to assign a relative "weight" to the preference for that associated kind of content. This weight is referred to as a "quality value" (or "qvalue") because the same parameter name is often used within server configurations to assign a weight to the relative quality of the various representations that can be selected for a resource."

[0] https://www.rfc-editor.org/rfc/rfc9110.html#quality.values

[1] https://developer.mozilla.org/en-US/docs/Glossary/Quality_va...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: