accept-language header, api response incorrect
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Software Center Agent |
New
|
Undecided
|
Unassigned |
Bug Description
Any reference to fr lang in the Accept-Language header results in results being returned in French (if available), despite en being preferred in the header:
sstewart at Kelpie in ~
$ curl -H "Accept-Language: en-GB,en" https:/
% Total % Received % Xferd Average Speed Time Time Time Current
100 3006 100 3006 0 0 12203 0 --:--:-- --:--:-- --:--:-- 12170
"Mobile OTP Transit Planner for Paris"
sstewart at Kelpie in ~
$ curl -H "Accept-Language: en-GB,en;
% Total % Received % Xferd Average Speed Time Time Time Current
100 2888 100 2888 0 0 13505 0 --:--:-- --:--:-- --:--:-- 13558
"Planificateur de trajets en transports en commun pour Paris"
affects: | software-center-agent → click-package-index |
After some further investigation, I finally figured out the cause of this:
* Package metadata is assumed to be English by default.
* Translations are embedded within the package metadata.
* When an Accept-Language header is passed by the client:
* The languages are ordered by preference.
* The default "English" metadata is used as a starting point.
* The translations are checked for each of the preferred languages.
* When a match is found, the translated data is overlaid.
This means that English rarely, maybe never, appears in the translations. Consequently, a client specifying English as its preference and another language as a fall-back will always get the fall-back language if it is present in a package's metadata.