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