Page MenuHomePhabricator

Improve Accept-Language header handling in RESTBase
Open, HighPublic

Description

Story
"As a user of the Page Content Service, I want to send a standard Accept-Language header with my request and receive the appropriate language variant in the response."

Designs/Interface/Mockups

On a request to sr.wikipedia.org, Accept-Language: en, sr-Latn;q=0.9, sr-Cyrl;q=0.8 would be reduced to sr-el.

On a request to zh.wikipedia.org, Accept-Language: en, zh-tw;q=0.5 would be reduced to zh-tw.

There is code in the mobileapps service that handles this reduction. It sorts the codes by q score and the converts from IETF language tags to Wikipedia language codes to pick the most relevant language code. It should just be a matter of moving that code upstream into RESTBase. The code only handles zhwiki and srwiki at the moment but could be expanded to other wikis with variants.

Done Criteria

  • Requests that pass a standard accept language header utilize the highest-ranked language code and variant that's relevant to the domain.

Specific Examples:

  • curl "https://sr.wikipedia.org/api/rest_v1/page/summary/%D0%A1%D1%80%D0%B1%D0%B8%D1%98%D0%B0" -H "Accept-Language: en, sr-Latn;q=0.9, sr-Cyrl;q=0.8" picks sr-el as the appropriate wiki language variant. The returned displaytitle should be Srbija and not Србија.
  • curl "https://zh.wikipedia.org/api/rest_v1/page/summary/%E4%B8%AD%E5%9C%8B" -H "Accept-Language: en, zh-hans;q=0.5" picks zh-hans as the appropriate wiki language variant. The returned displaytitle should be 中国 and not 中國.
  • The above examples return the correct variant for other Page Content Service endpoints - /page/mobile-html, /page/media-list

Event Timeline

JoeWalsh created this task.Jun 26 2020, 3:32 PM
Restricted Application added subscribers: Petar.petkovic, Cosine02, Aklapper. · View Herald TranscriptJun 26 2020, 3:32 PM
JoeWalsh triaged this task as High priority.Jun 26 2020, 3:33 PM

@JoeWalsh: Assuming this task is about the RESTBase code project, hence adding that project tag so other people who don't know or don't care about team tags can also find this task when searching via projects. Please set appropriate project tags when possible. Thanks!

VulpesVulpes825 added a subscriber: VulpesVulpes825.

Adding Chinese-Sites to keep tracking issue that relate to T254627.

Shizhao moved this task from Backlog to MediaWiki core on the Chinese-Sites board.Thu, Jul 9, 1:27 AM