Page MenuHomePhabricator

“Preview page with this template” broken with translatable templates
Open, MediumPublic

Description

  1. Open for edition a template which is marked for translation, e.g. meta:Template:WikiForHumanRights/2021/Events/table
  2. Make a visually noticeable change (e.g. add some text outside of noinclude parts)
  3. Preview your template: you well can see your change.
  4. Preview a page with this template (e.g. meta:WikiForHumanRights/Organize)

Expected: you well can see your change where the template is displayed.
Actually: template change does not appear on the preview.

Maybe a regression due to T47096: Add a way to transclude template or other page in the correct language?

Event Timeline

As far as I know, this preview has never worked with translatable pages, neither with the legacy {{#switch:<translate></translate> hack (provided that you changed something within the empty branch of the switch, which is equivalent to the whole template in the new system).

I’m not sure that enabling it would be the right thing, either—if you hit the publish button, the pages transcluding the template will not change until a translation administrator remarks the page for translation. This means that if the preview function used the new version used the version in the edit field, it would probably make the user think that publishing the edit will immediately change the pages transcluding the template, and thus would create more confusion than the current situation. Also, what do you expect if you preview the French translation? It transcludes the French translation of the template, not the English. Currently it’s clear: English pages transclude the /en subpage, French pages transclude the /fr subpage (if it exists).

Right, page must be marked for translation, my bad. So, not a regression.

However, there is currently no way to preview a translatable template in real context. I understand @Tacsipacsi fears, but I think they could be got around with an additional “Simulate translation awareness” checkbox or something like that.
Also, “Preview page with this template” seems me already an expert function, we don’t need to be so careful.

This is incredibly annoying when trying to improve templates on mediawiki.org (which sometimes uses translation way too much for its own good), especially when one isn't a translation admin. Since the preview already overrides what wikitext to use, ignoring translations is only logical.

Is this a core bug? Translate uses BeforeParserFetchTemplateRevisionRecord, TemplateSandbox uses ParserOptions::setCurrentRevisionRecordCallback(); I would have expected the revision callback to win, but actually the hook takes priority. That feels wrong - something set within the scope of a single parse is probably more specific than a hook that always gets called.

Please note that just changing the precedence won’t achieve what you want: the translation syntax won’t be removed from the to-be-transcluded template, causing translation syntax to become visible everywhere, breaking links, templates, and so on. Try transcluding a non-template page that has “no transclusion support” notice on Special:PageTranslation (e.g. Manual:Lag.php) – that’s what happens when the BeforeParserFetchTemplateRevisionRecord hook handler doesn’t do anything. (Most templates with this notice will not appear broken, because they (ab)use this breakage to provide UI language-based translation.)