How does i18n on /api/2/metadata work?

I’ve been trying to figure out how i18n on /api/2/metadata works; if I set my language to German in the user settings, then it first returns English in the metadata, and then it does exactly the same request again with every header etc. exactly the same, and now it returns German (locale is de instead of en, strings are translated).

I’ve been reading through the code for a bit now, but I have no idea how this works, or even how it could possibly work. I assume it has some internal state somewhere, but how does it know to send back English again when I press F5 and do a hard reset? First I thought it must be the X-Aleph-Session, but that’s the same after a refresh as well.

(It needs to do both those requests; if it always returns English or always returns German then the frontend breaks).

(Tested with 3.17.0 locally and 4.0.0-rc57 on https://aleph.occrp.org – both behave identical).

Howdy @arp242

language preferences are stored on the server, in order for these to take effect you would need to be logged in. Once logged in requests are handled in the language of your choice, but if you are logged out then you’ll only see things in English.

My guess is that you are losing something on the f5 which stops aleph seeing the language that you have selected. Perhaps you are supplying an API key that is being lost.

If you can provide some more detailed steps to reproduce the issue we can help out a little more?

@arp242 replied to me saying

Turns out it does just set the Accept-Language header.