Page MenuHomePhabricator

Basic support for block templates in Section translation
Open, HighPublic

Description

As part of the support for templates in Section Translation (T275374), we want to provide basic support to block templates (infoboxes and other templates displayed as a separate paragraph).

Overview - mvp.png (768×1 px, 139 KB)

The key aspects to support are:

  • Highlight the whole template as a unit.
  • Show a specific template card with information and options. These will be based on the availability of the template and the parameter mappings in the target language.
  • Support editing the template using the standard editor with the "original" panel showing the source contents on top.

Highlight

Block templates should get highlighted as a unit when they become selected in the same way that sentences do. The interaction and styling should be consistent with those: taping them or moving to the previous or next element should move the highlight sequentially from sentences and templates in the order they appear in the article.

Template card

A custom card will replace the card proposing a translation. For templates, the contents fo the template are not shown translated due to the limited space. Instead, the following is shown:

  • Source template name with a template icon.
  • Suggested template with an option to edit it and an indicator communicating the parameter mapping.
    • If there is no equivalent template, a message indicating so will be shown.
  • Option to use a different template instead. This will open the dialog to insert a new template to replace the source one with it.

Template card.png (768×1 px, 69 KB)

Mapping success

The template card communicates the degree to which the template can be automatically transferred to the target language. It will cover the following cases:

  • No equivalent template. Wikidata shows no equivalent template for the source template.
  • No parameters match (for templates with parameters).
  • Parameters matching (indicating how much).

The percentage used to fill the circle will consider both, the parameters with data from the source template that can be mapped and the mandatory parameters form the target template that remain to be filled. For example, a
The formula for calculation could look similar to this:

success_percentage = source_filled_parameters_successfully_mapped / (source_filled_parameters + target_mandatory_empty)

For example, given a source template with 20 possible parameters where 10 are filled with data, if 6 parameters can be mapped to the target template and there are 2 mandatory parameters in the target template that cannot be filled, the circle will be 50% filled (6/(10 + 2)). This will give a sense of the pending work to be done for completing the translation of the template.

Especial consideration is needed for the cases where the source template has no filled parameters (or no parameters at all):

  • A source template with no parameters filed will be represented as 100% completed if there are no mandatory parameters unfilled in the target template.
  • A source template with no parameters filed will be represented as 0% completed if there are mandatory parameters unfilled in the target template.

Mapping.png (768×1 px, 73 KB)

Layout, sizing and styling details

Template card Layout.png (768×1 px, 87 KB)

Template editor

For the initial support, the standard Template editor of Visual editor will be reused when editing a template.
The "Original" panel will be added on top as with regular sentence editing to show the contents of the source template.

The contents of the source template will be displayed as key value pairs one after the other with the parameter name in bold above the value.

Template editor - mvp.png (768×1 px, 43 KB)


Until the current ticket is completed, we may want to hide the block templates (T294066).

Follow-up tickets will cover additional features not included in the scope of the current one:

  • Additional explanations when taping on the template mapping symbols (T295545)
  • Keeping the original panel in sync with the field selected in the template editor
  • Applying MT in the template editor

Event Timeline

Pginer-WMF triaged this task as Medium priority.Oct 29 2021, 3:41 PM
Pginer-WMF created this task.
Pginer-WMF updated the task description. (Show Details)
Pginer-WMF raised the priority of this task from Medium to High.Nov 2 2021, 8:40 AM
ngkountas removed ngkountas as the assignee of this task.
ngkountas added a subscriber: ngkountas.

Change 741946 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Support block template concept inside vuex and pageSection model

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

Change 741951 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Remove line breaks from \"fetchSegmentTranslation\" method response

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

Change 742179 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX translator api: Add adaptBlockTemplate method

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

Change 742180 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Remove blockTemplateProposedTranslation model

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

Change 742181 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX vuex translateTranslationUnitById action: support block templates

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

Change 742182 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX vuex actions: Adapt block template before applying edit

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

Change 741951 merged by Nik Gkountas:

[mediawiki/extensions/ContentTranslation@master] SX: Remove line breaks from \"fetchSegmentTranslation\" method response

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