Content translation/Specification

Prototype
The prototype which acts as design reference too is present at: http://pauginer.github.io/prototype-translate/content-translation.html

Architecture
See architecture documentation

Widgets
The CX UI consists of 4 component widgets - The header, source article widget, translation widget, translation tools widget.

Communication between Widgets
We separate the responsibilities and follow an event driven approach. Imagine it as a global single event dispatcher. Widgets subscribe to events, widgets publish events (fire), widgets can attach and detach from the event registers.

Suppose you click on a word in source article. We wont call any methods of other widgets. we will pretend that the source article widget does not know about other widgets. On click of a word, the widget will raise/publish an event say mw.ex.source.word.select. Now, multiple consumers can subscribe to this event. One would be the translation column. Other will be the tools widget-inside tools we are going to have a lot of translation helpers.

For event subscribe/publish pattern, we use mw.hook, which is a wrapper on top of $.Callbacks.

UI styling
LESS is used for the extension.

Naming conventions

 * ContentTranslation is abbreviated everywhere as cx.
 * All CSS class names should have a prefix cx
 * All RL modules have a prefix ext.cx
 * The jquery object namespace is mw.cx
 * CSS classes follow BEM naming conventions
 * Follows MW coding, naming conventions
 * As of late 2016, transition to OOJS is in progress

Workflow

 * Starting: From an entry point ("gray interlanguage link"), through a direct link, or through the dashboard
 * Loading the source article and the translation side by side.
 * Initial load: The source column must show a loading indicator. The translation column must have no content.  The "+ Add translation" placeholder must be shown in the first section, or in other sections on hover.
 * During translation, each section is auto-saved to a central parallel corpora database.
 * Loading a saved translation: The source and the target column must show loading indicators. The translated text must be loaded with the same content as it had when it was auto-saved.
 * Clicking an empty section pre-fills the translation.
 * If the user selected "no automatic translation", it must remain empty.
 * If the user selected "source text", the source text must be pre-filled with link, reference and template adaptation.
 * If the user selected an MT engine, the machine-translated text must be pre-filled with link, reference and template adaptation.
 * Links
 * Link are adapted automatically when using automatic translation.
 * If text is selected in the target column that can be linked to an existing article in the target wiki, the link card must be shown that allows to link to it.
 * It must be possible to add a link to a non-existing ("red") target article.
 * Clicking a link in the source column must show a link card with the source article (with title and image if available). If a directly corresponding target article exists, it must be shown, too.  If not, the user must have the possibility to link to a different article.
 * References
 * Clicking a reference must show reference adaptation card
 * Math
 * formulas are copied as-is.
 * Templates
 * A template can be skipped, copied as source (possibly dysfunctional in the target language), or adapted in detail if an equivalent template exists
 * Equivalent template adaptation is described in Templates
 * Categories
 * Directly corresponding categories are adapted automatically.
 * Publishing
 * The article is published as a full-fledged wiki page.
 * Interlanguage links are added using Wikidata sitelinks.

URL structure
Content Translation mainly works on the special page Special:ContentTranslation. The URL parameters are:


 * page &mdash; source title
 * targettitle &mdash; target title
 * from &mdash; source language
 * to &mdash; target language
 * campaign &mdash; campaign name, mainly for logging purposes

Testing
(To be redefined in January 2017.)

Bug reports
Please report bugs to [ //phabricator.wikimedia.org/maniphest/task/create/?projects=MediaWiki-extensions-ContentTranslation Phabricator using the "MediaWiki-extensions-ContentTranslation" project]. Don't worry about specifying version, severity, hardware, or OS if you don't know.