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).
- 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.
- 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.
- On https://en.wikipedia.beta.wmflabs.org/wiki/Category:Page_Previews hover over a link. Inspect the developer tools "network" tab to ensure that the request made to the rest api has Accept-language set to "en".
- Visit https://zh.wikipedia.beta.wmflabs.org/wiki/Special:AllPages. API requests caused by hovering over links should send requests where Accept-language set to "zh"
- Visit https://zh.wikipedia.beta.wmflabs.org/wiki/Special:%E5%8F%82%E6%95%B0%E8%AE%BE%E7%BD%AE set language in 2nd drop down to zh-HK
- Now when triggering a page preview API requests should besent with Accept-language set to "zh-HK"
- Note: In all of the above there should be no difference in the display of page previews