Extension:Translate/Mass migration tools/Alignment
Appearance
(Redirected from Extension:Translate/Mass migration tools/Design)
Assumptions:
- The translation has paragraphs in the same order as the original
The step 2 of this project requires importing the translations which were already present before FuzzyBot's edit to the page. These need to be aligned with the translation unit identifiers made by the Translate extension.
As per the mock up design, the only thing we need to worry about is filling out the left and right hand side blocks with appropriate texts. The left hand side blocks are for the source text (English) and the right hand side blocks are for the corresponding imported translations.
- Left-hand-side blocks: The left-hand side blocks would contain the source text and would not be editable. The source units would be obtained using the WebApi and
list=messagecollection
- Right-hand-side blocks: The right hand side blocks would contain the translations of the language code specified for a given page. The logic involved would be as follows:
- Find the timestamp of FuzzyBot's oldest edit on the page using the WebApi
prop=revisions
andrvuser=FuzzyBot
- Reduce the timestamp by 1 second and use it as the starting timestamp for
prop=revisions
to get the revision before FuzzyBot's revision on the page. - Fetch the text for that revision and split it on double newlines ('\n\n') to obtain the translation units on paragraph level.
- Split the resulting units so that there does not exist a unit containing a mix of headers and other wiki text.
- Once the units are split on '\n\n' and headers are separated from other wikitext, align them on h2 level, i.e, the first h2 header in source should match with the first h2 header in target. Empty units can be added or units could be collapsed if there is not enough room to align.
- After this, the user can manually adjust the units by using the features mentioned below.
- Find the timestamp of FuzzyBot's oldest edit on the page using the WebApi
- Import features: Corresponding to each translation (target) unit, a set of features would be added. These include:
- Delete unit: This deletes the corresponding unit and shifts the target units up.
- Add a unit below: This adds an empty unit below the current unit.
- Swap with unit below: This swaps the text of the current unit with the unit below.