When a client requests rendered page content from a page/{title}/html and revision/{title}/html endpoint, it should be able to specify the desired language variant in the Accept-Language header. If necessary and possible, the endpoint should apply language variant conversion (e.g. cyrillic serbian to roman serbian, traditional chinese to simplified chinese, tec).
Currently, language variant conversion is supported by the /transform/from/html/to/html endpoint, but the client would have to supply the HTML of the content to be converted. So clients would have to first load the content HTML, then send it back for conversion. The goal of this ticket is to avoid the additional round trip.
Implementation Notes
The conversion is currently implemented in ParsoidHandler::languageConversion. However, we intent to remove ParsoidHandler in the near future. All behavior should be factored out of that class, into either service objects, or handler "helper" objects.
The "helper" used for getting page HTML is HtmlOutputRendererHelper. This is where language conversion needs to happen in order to fulfill this ticket. However, we need to retain the old behavior as well, offering language conversion as a separate transformation. It would probably be best to extract ParsoidHandler::languageConversion into a service object, which can then be called from HtmlOutputRendererHelper as well as from ParsoidHandler.
Considerations
We will likely want to be able to mix and match different transformations that can be applied to page content HTML. ParoisHandler::pb2pb currently supports two: language variant conversion, and redlinks. Since we are likely to add more such transformations (e.g. TOC generation), perhaps a factory approach would be appropriate. We also already have an HTMLTransformFactory and HTMLTransform (for transforming HTML to wikitext). We could introduce a LanguageConversion that performs the conversion, and give HTMLTransformFactory a getLanguageConversion() method.