Page MenuHomePhabricator

Parsoid should support multilingual SVG thumbnails in page language
Closed, ResolvedPublic

Description

This support was added to core in T205040 (I348840ef405e1370cc0c17d69051bce30153c9c0) and needs to be ported to Parsoid. Parsertests for this feature were added to the blacklist in Ic4e77a06638770e7439edcce1572bfe26f5838ad


Copied from duplicate T247671

Steps to Reproduce:
Edit https://de.wikipedia.org/w/index.php?title=COVID-19&direction=prev&oldid=197763810#Vorbeugung with 2017-wikitext-editor

Image from https://commons.wikimedia.org/w/index.php?title=File:COVID-19_Health_care_limit.svg&lang=de

If I use a image such as [[File:COVID-19_Health_care_limit.svg|mini|lang=de|description]] it shows the image in the default language (e.g. english) not in German (de). As soon as I save the page it is in German. Since I create multilingual svgs, I would like to check them before using in articles.

This image is used here:

https://de.wikipedia.org/w/index.php?title=COVID-19&direction=prev&oldid=197763810#Vorbeugung

Actual Results:
dispays the image with the default language (english)

220px-COVID-19_Health_care_limit.svg.png (103×220 px, 5 KB)

Expected Results:
display the image in German (lang=de)

langde-220px-COVID-19_Health_care_limit.svg2.png (103×220 px, 5 KB)

Event Timeline

Starting points, copied from IRC:

the first step would be to do some research: look at the patch that was landed to enable this support in the core parser (linked from T205040)
figure out what the filenames for the language-specific svg thumbnails look like (there's an example in the phabricator task comments, but you should verify against the code)
then look at the info returned by the imageinfo API request to see if the required information is present
assuming it is, you'd then (1) add code to tokenize/parse the "lang" option (this might already be present)
(2) tweak the parsoid code which does the imageinfo request to pass along the language; hopefully this will return the right thumbnail URLs from core
(3) check that the parsertests for this feature now pass and/or add new tests (or new parsoid-specific test output for existing tests)
on the parsoid side, all the code you'd need to alter should be in lib/mw/ApiRequest.js lib/mw/Batcher.js lib/wt2html/tt/LinkHandler.js and tests/mockAPI.js:
if you don't already know about https://en.wikipedia.org/wiki/Special:ApiSandbox it will probably be very helpful
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo&titles=File%3AAlbert%20Einstein%20Head.jpg&iiprop=url%7Cmediatype%7Cmime%7Csize&iiurlwidth=200
is an example imageinfo request that returns thumbnail urls
so the goal would be to tweak that request (as made by parsoid) to return the proper language-specific thumbnail urls

I'm sorry that I never got around to working on this.

JoKalliauer renamed this task from Parsoid should support SVG thumbnails in page language to Parsoid should support multilingual SVG thumbnails in page language.Mar 15 2020, 6:25 AM
JoKalliauer updated the task description. (Show Details)

Change 757520 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] [WIP] Support lang= option for SVGs

https://gerrit.wikimedia.org/r/757520

Change 757980 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] [WIP] Support rendering SVG based on page language

https://gerrit.wikimedia.org/r/757980

Change 757520 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Support lang= option for SVGs

https://gerrit.wikimedia.org/r/757520

Change 758585 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.15.0-a18

https://gerrit.wikimedia.org/r/758585

Change 758585 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.15.0-a18

https://gerrit.wikimedia.org/r/758585

Parsoid now respects the lang= option,
https://de.wikipedia.org/api/rest_v1/page/html/COVID-19/197763810#Vorbeugung

However, T205040 is also about falling back the page language which is still to be done.

Change 770627 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/core@master] Use badfilecontexttitle to set targetlang for imageinfo requests

https://gerrit.wikimedia.org/r/770627

Change 771079 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Add html/parsoid sections for svg rendering by page language tests

https://gerrit.wikimedia.org/r/771079

Change 757980 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Support rendering SVG based on page language

https://gerrit.wikimedia.org/r/757980

Change 771079 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Add html/parsoid sections for svg rendering by page language tests

https://gerrit.wikimedia.org/r/771079

Change 770627 merged by jenkins-bot:

[mediawiki/core@master] Use badfilecontexttitle to set targetlang for imageinfo requests

https://gerrit.wikimedia.org/r/770627

Change 772510 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.16.0-a1

https://gerrit.wikimedia.org/r/772510

Change 772510 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.16.0-a1

https://gerrit.wikimedia.org/r/772510