Page MenuHomePhabricator

Return description in the correct language variant from /page/summary
Closed, ResolvedPublic

Description

Background information

/page/summary doesn't return description in the correct language variant

How

Request the description in the correct language variant from Wikidata based on the accept language header.

For example, requesting https://sr.wikipedia.org/api/rest_v1/page/summary/Србија with Accept-Language: en, sr-Latn;q=0.9, sr-Cyrl;q=0.8 should return Serbian (Latin script) description from Wikidata. It would achieve this by passing sr-el as the languages parameter to wbgetentities since sr-Latn is higher than sr-Cyrl in the list of preferred languages.

https://wikidata.org/w/api.php?action=wbgetentities&format=json&ids=Q403&languages=sr-el

Open questions

As proposed, /page/summary would only return content in one of the language variants associated with the wiki in the request. In the example above, English could be requested from Wikidata since it's the most preferred language. However, given the domain of the request is sr.wikipedia.org, it should only return one of the Serbian variants.

Acceptance criteria

  • For wikis that have language variants, the correct description is returned from /page/summary based on the Accept-Language header.

Other examples

https://zh.wikipedia.org/api/rest_v1/page/summary/中國 with zh-Hans as the most preferred Chinese language variant in the Accept-Language header would return the Simplified Chinese description from https://www.wikidata.org/wiki/Q29520 and with zh-Hant as the most preferred Chinese language variant in the Accept-Language header would return the Traditional Chinese description.

Event Timeline

For testing it might be easier to have another example from srwiki. 1) It might work earlier. 2) Seeing the difference between Cyrillic and Latin is easier for most westerners.

Picking this up as the issue is made worse in mobile-html since the summary response is used for the title:

Simulator Screen Shot - iPhone X - 2019-07-31 at 08.33.13.png (2×1 px, 274 KB)