Page MenuHomePhabricator

Special treatment for translation unit marker comments in <translate>
Open, Needs TriagePublic

Description

[subbu@earth:~/work/wmf/parsoid] echo '<translate><!--T:1--> foo</translate>' | php bin/parse.php
<meta typeof="mw:Annotation/translate" data-parsoid='{"dsr":[0,11,null,null]}' data-mw='{"rangeId":"mwa0","extendedRange":true,"wtOffsets":[0,11]}'/><!--T:1--><pre data-parsoid='{"dsr":[21,37,1,0]}'>foo</pre><meta typeof="mw:Annotation/translate/End" data-parsoid='{"dsr":[25,37,null,null],"wasMoved":true}' data-mw='{"wtOffsets":[25,37]}'/>

That should not generate a <pre> like other usual comments. PreHandler might need a special check for <!--T:\d*--> comments OR we need to recognize them in the tokenize and add special marker nodes that are then replaced in the CleanUp pass OR some other solution that seems appropriate.

Event Timeline

Note even if Translate extension generates only digital-Id markers, it well handles (legacy support) string as identifier for unit markers.
This hacky feature is sometimes (rarely) used: example with meta:Template:I18n/Reports.

I don’t know benefits/costs ratio, but we could maybe refactor marker syntax (e.g. <!--T:55--><tunit id=55 />), as we’ve done for tvar syntax (T274881).

As an additional bonus...

$ echo -e '<translate><!--T:1--> hello</translate>\n<translate><!--T:2--> world</translate>' | php ./bin/parse.php --wt2wt
<translate><!--T:1-->
 hello
<!--T:2--> world
</translate>

Both <pre> get combined, which means the first translate gets extended, which means the second translate gets removed because it's nested. Which might not be an issue per se, except for the fact that this specific syntax then gets rejected because "Multiple translation unit markers for one translation unit".

Change 742124 had a related patch set uploaded (by Isabelle Hurbain-Palatin; author: Isabelle Hurbain-Palatin):

[mediawiki/services/parsoid@master] Treat translation unit marker comments as not-SOL transparent

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

Test wiki created on Patch demo by IHurbainPalatin (WMF) using patch(es) linked to this task:

https://patchdemo.wmflabs.org/wikis/b6ad2f0f03/w/

Change 742124 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Treat translation unit marker comments as not-SOL transparent

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

Change 742570 had a related patch set uploaded (by Sbailey; author: Sbailey):

[mediawiki/vendor@master] Bump Parsoid to 0.15.0-a11

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

Change 742570 merged by jenkins-bot:

[mediawiki/vendor@master] Bump Parsoid to 0.15.0-a11

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

Test wiki on Patch demo by IHurbainPalatin (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/b6ad2f0f03/w/