Page MenuHomePhabricator

Support language variants in Proton
Open, HighPublic

Description

Background information

Wikis have content in different language variants, that will get rendered depending on the language sent by the user agent.

Right now, the server side PDF renderer doesn't do anything particularly smart with the language, resulting in PDFs that are always rendered in the default variant for the wiki.

This makes it impossible to get PDFs in different variants in wikis like the chinese and serbian.

What

It should be possible to get rendered PDFs with a different language variant.

How

Proton should take into account the language header (accept-language) in the requests, and forward it to the renderer process in the best way possible.

The simplest solution could be just setting the language in chrome at instantiation, passing args: ['--lang=bn-BD,bn'] when doing a .launch, and that should automatically add the appropriate headers to all requests. Chrome args, Puppeteer docs.

If this approach had any problems, we can probably do with [page.setExtraHTTPHeaders(headers)](https://pptr.dev/#?product=Puppeteer&version=v1.12.2&show=api-pagesetextrahttpheadersheaders) instead, setting Accept-Language there manually before making the page go to the wiki URL.

Acceptance criteria

  • Asking for a PDF sending a language variant header in the request, should result in the PDF content rendered in the requested language variant

Related tasks

Event Timeline

Jhernandez subscribed.

Seems like product hasn't prioritized this for now so moving to backlog as low

Jhernandez raised the priority of this task from Low to Medium.Jan 15 2019, 11:47 AM

Why is this dependent on Parsoid?

The restbase part for accepting and forwarding the header should be done, as we did adapt the other rest services to pass it along.

We would have to adapt proton to take the header and pass it to chromium either setting the navigator language or passing the header when loading the request.

Technically not dependent, just easier to develop/test once you can see some effect from doing it, I imagine.

@ovasileva Do you have an idea about the priority of this feature?

@Jhernandez - I would say let's keep it as normal - we've gotten a couple of requests for this in the past from users and I would say it makes a big different on projects with language variants.

Jhernandez raised the priority of this task from Medium to High.Feb 25 2019, 1:10 PM

Fleshed out the task, and making it high since it seems more important than the other proton tasks in the backlog

Change 896035 had a related patch set uploaded (by Winston Sung; author: Winston Sung):

[mediawiki/extensions/ElectronPdfService@master] ElectronPdfService: Make sure page view language being handled in URL

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