Is the language order in the Accept-language HTTP field consistent?

I was wondering if the order of the actual languages ​​is in Accept-language. For example, if our HTTP GET message contains a header:

Accept-Language: en-us, en-gb;q=0.2, en;q=0.3, fr, fr-ch, da, fi 

... the browser prefers traditional French (fr) over the Swiss French (fr-ch), although both of them do not have a negative quality factor q, and therefore will be 1.

+3
source share
2 answers

No, the order does not matter.

+2
source

When I did this, I used the stable view so that values ​​with the same relative q-value remained in the same relative order. I believe this is logical and probably reflects the intent of the specification :

Please note that some recipients consider the order in which language tags are listed as an indicator of descending priority, especially for tags that are assigned equal qualitative values ​​(the value does not match q = 1). However, this behavior cannot be relied upon. To ensure consistency and maximize interoperability, many user agents assign each language a tag with a unique quality value, as well as listing them in decreasing order of quality. An additional discussion of language priority lists can be found in Section 2.3 of RFC4647 .

As an example, where this behavior might be desirable if you have a layer / caching middleware and you are processing Accept* headers in an unstable way (e.g. maybe random selection if they all have the same q value), while as you may not be mistaken, but the results will be unpredictable, and this can cause problems at the cache level and a poor user interface (for example, changing the language between pages for some obvious reason).

0
source

Source: https://habr.com/ru/post/1335448/


All Articles