Page MenuHomePhabricator

Send the Accept-Language header with RESTBase API request for page preview requests
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

From T188164#4324348:

Per discussion on the Audiences-Services sync meeting, the initial step on the Page-Previews side could be to just explicitly set the Accept-Language header to the current wiki language code with no variant.

AIUI doing so will unblock Services rolling out language variant support for RESTBase and the Page Summary endpoint in particular. Moreover, landing language variant support for that endpoint will unblock T111231: Page previews for Wikidata (blocked by T198465: Enable language variants support for summary amongst others).

AC

  • When Page Previews makes a request to the Page Summary endpoint:
    • It includes the Accept-Language header
    • The value of the Accept-Language header is the current wiki's language code verbatim, i.e. $wgContentLanguage.

Notes

  1. MediaWiki's language codes differ from ISO language codes in a number of different cases. Use the MediaWiki-provided language code (wgPreferredVariant) as that'll be handed to Parsoid/MediaWiki and that's what they understand.

    See T198619#4387451, for additional detail about why this is important.

QA steps

Event Timeline

ovasileva triaged this task as Medium priority.Jul 2 2018, 2:01 PM

Isn't Accept-Language sent automatically from the browser passing the default language of said browser...?

MediaWiki's language codes differ from ISO language codes in a number of different cases. Use the MediaWiki-provided language code as that'll be handed to Parsoid/MediaWiki and that's what they understand.

Because https://phabricator.wikimedia.org/T198619#4387117 I think this logic should live in the services layer tbh.

Isn't Accept-Language sent automatically from the browser passing the default language of said browser...?

It is and that is the problem for us in many ways:

  1. It will split the cache - the wikis that support variants will set vary: accept-language, so if a person with en as a default language comes to serbian wiki - everything will become pretty slow for him
  1. Browser default variant might be VERY much not what we want to set. Just as example: in MW for Serbian sr is no variant, sr-el is latin serbian and sr-ec is Cyrillic. The actual standard have sr, sr-latn and sr-cyrl. However Safari sets just sr for latin Serbian and sr-cr for Cyrillic, which is not only not following any standard, but also clashes with Mediawiki no-variant and that's just one example I found, I'm sure there's more. So I think we should control what exactly we send, not let the browser do it.
  1. Depending on product decision we might want to send something other then what the user's browser setting are. For example, user preferred variant, or the variant currently selected for the particular article the user is reading now.

Thanks for explaining this. This makes a lot more sense now with this context!

ovasileva raised the priority of this task from Medium to High.Jul 3 2018, 2:02 PM
Jdlrobson renamed this task from Send the Accept-Language header with RESTBase API request to Send the Accept-Language header with RESTBase API request for page preview requests.Jul 3 2018, 4:13 PM
pmiazga set the point value for this task to 2.Jul 3 2018, 4:22 PM

Change 443746 had a related patch set uploaded (by Pmiazga; owner: Pmiazga):
[mediawiki/extensions/Popups@master] Send the Accept-Language header when calling API

https://gerrit.wikimedia.org/r/443746

I switched my local wiki to Chinese and chose Chinese HK as my variant language

Screen Shot 2018-07-03 at 3.57.06 PM.png (327×726 px, 55 KB)

Variant is set correctly in header

Screen Shot 2018-07-05 at 11.38.03 AM.png (139×663 px, 31 KB)

Change 443746 merged by jenkins-bot:
[mediawiki/extensions/Popups@master] Send the Accept-Language header when calling API

https://gerrit.wikimedia.org/r/443746

Alex probably nothing for you to care about here, but offering this to you just in case :)

@Jdlrobson ok going to pass over to Anthony. FYI I'm not seeing any page previews, or network requests, when I hover over links on https://en.wikipedia.beta.wmflabs.org/wiki/Special:AllPages

I can see that the a header is set to sr on Cerbian wiki - bravo, that unblocks us from deploying the language variants for the summary endpoint and if I change my preferences I can see sr-ec and sr-el. Thank you, I think this could be resolved.