As a user of screen readers, I want my screen reader the label and description in the correct language in order to understand them well.
Problem:
Right now the wbsearchentities API does not return the language for labels and descriptions. It should. The current behavior is especially problematic when the returned match contains a label and description from a fallback language.
Example:
What the API currently returns with https://www.wikidata.org/w/api.php?action=wbsearchentities&search=%D9%85%D9%84%D8%B9%D8%A8%20%D9%88%D9%8A%D9%83%D9%8A%20%D8%AF%D8%A7%D8%AA%D8%A7&language=ar&uselang=ar&formatversion=2
{ "searchinfo": { "search": "ملعب ويكي داتا" }, "search": [ { "id": "Q4115189", "title": "Q4115189", "pageid": 4246474, "repository": "wikidata", "url": "//www.wikidata.org/wiki/Q4115189", "concepturi": "http://www.wikidata.org/entity/Q4115189", "label": "ملعب ويكي داتا", "description": "item for experimenting", "match": { "type": "label", "language": "ar", "text": "ملعب ويكي داتا" } } ], "success": 1 }
We want something like this:
{ "searchinfo": { "search": "ملعب ويكي داتا" }, "search": [ { "id": "Q4115189", "title": "Q4115189", "pageid": 4246474, "repository": "wikidata", "url": "//www.wikidata.org/wiki/Q4115189", "concepturi": "http://www.wikidata.org/entity/Q4115189", "label": "ملعب ويكي داتا", "description": "item for experimenting", "match": { "type": "label", "language": "ar", "text": "ملعب ويكي داتا" }, "display": { "label" { "language":"ar", "text": "ملعب ويكي داتا" }, "description": { "language":"en", "text": "item for experimenting" } } } ], "success": 1 }
BDD
GIVEN a call to the wbsearchentities api
WHEN returning a match
THEN the language for the label and description is returned as well
Acceptance criteria:
- wbsearchentities returns the language for labels and descriptions of returned matches
Note:
- This should not be a breaking change but we should communicate it.
Original report:
wbsearchentities used to return label, description, and (if matched) aliases in the requested search language (or fallback language of that). This chanegd with T90692, which introduced an internal search interface that would provide the matched term in the search language (or one its fallback languages) and display terms (a label and a description) in the user language (or one of its fallback languages).
wbsearchentities will currently return the label and description in the user language, and the (single) matched term in the "aliases" slot, as plain strings. The rationale for this is the main use case for the "aliases" field: it allows the UI to show why a term was returned as a result to the search. In addition to the old "aliases" field, wbsearchentities now returns a "matched" field with the matched term as a full term structure.
We should add a "display" field, which would contain the full term structures (including the actual language) of the label and description. The old label, description, and alias fields should be deprecated. The Wikibase UI should be changed to only use the "matched" and "display" fields.
Follow-ups: