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

phuedx created this task.Jul 2 2018, 11:41 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 2 2018, 11:41 AM
Pchelolo awarded a token.
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!

phuedx updated the task description. (Show Details)Jul 2 2018, 4:16 PM
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
Jdlrobson updated the task description. (Show Details)Jul 3 2018, 4:17 PM
pmiazga set the point value for this task to 2.Jul 3 2018, 4:22 PM
pmiazga claimed this task.Jul 3 2018, 9:03 PM
pmiazga moved this task from To Do to Doing on the Readers-Web-Kanbanana-Board-Old board.

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

pmiazga removed pmiazga as the assignee of this task.Jul 3 2018, 10:31 PM
pmiazga moved this task from Doing to Needs Code Review on the Readers-Web-Kanbanana-Board-Old board.

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

Variant is set correctly in header

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

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

Jdlrobson updated the task description. (Show Details)Jul 5 2018, 8:28 PM
Restricted Application added a subscriber: Cosine02. · View Herald TranscriptJul 5 2018, 8:28 PM

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

Shizhao moved this task from Backlog to MediaWiki core on the Chinese-Sites board.
alexhollender added a subscriber: alexhollender.

@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

Jdlrobson updated the task description. (Show Details)Jul 11 2018, 8:33 PM

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.

Shizhao moved this task from MediaWiki core to Closed on the Chinese-Sites board.Jul 13 2018, 3:50 AM