Add a way to transclude template or other page in the correct language
Open, HighPublic

Tokens
"Orange Medal" token, awarded by Krinkle."Love" token, awarded by gpaumier."Like" token, awarded by Glaisher."Mountain of Wealth" token, awarded by Nemo_bis.
Assigned To
None
Authored By
Yair_rand, Feb 17 2013

Description

(I'm assuming that Special:MyLanguage is part of the Translate extension.)

I think it would be helpful if it was possible to transclude Special:MyPage. For example, if a template is translated, the correct language version needs to be the one that is used, but one can't just input {{Special:MyLanguage/TemplateName}} to get it to work.

At some point https://www.mediawiki.org/w/index.php?title=Module:Template_translation&oldid=716205 was created which, used on the translatable template page, automatically fixed all transclusions (AKA transcluding pages, callers). The main goal of a built-in solution should probably be this: make it possible for a template to become translatable without requiring edits to all transcluding pages.


See Also:

Details

Reference
bz45096
bzimport raised the priority of this task from to Lowest.
bzimport set Reference to bz45096.
bzimport added a subscriber: Unknown Object (MLST).

"Correct language version" is not necessarily the user's interface language.
As far as I know there are no plans to cover this; Niklas didn't even wish to cover the topic of translatable templates in the docs.

I did not want to cover that in the docs because currently nothing exists to support them. That does not mean I'm against such feature. If it is done, it is likely to be done in a different way, however.

Using bug 41476, guillom created the Lua module https://meta.wikimedia.org/wiki/Module:Template_translation to replace/streamline {{Translatable navigation template}} created by jsoby and adapted by Kaganer, already in use on several Wikimedia wikis.

There is also a bug about adding a magic word/parser function to identify valid language codes, but I can't find it (or it was just my wish).

There is currently no way to invoke the language converter. Thus, we are not able to convert autotranslated templates which are transcluded to, for example user talk pages, to the language variants because they are blacklisted when using the translate extension for template translation.

Glaisher added a subscriber: Glaisher.

Change 213196 had a related patch set uploaded (by Nemo bis):
Allow transclusion with Special:MyLanguage

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

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 22 2015, 12:53 PM
Nemo_bis updated the task description. (Show Details)Jan 8 2016, 12:33 AM
Nemo_bis set Security to None.
Nemo_bis added a subscriber: Krinkle.
Nikerabbit renamed this task from Add way to transclude template or other page in the correct language, e.g. with Special:MyLanguage to Add a way to transclude template or other page in the correct language.Mar 23 2016, 7:53 AM
Nikerabbit raised the priority of this task from Lowest to High.
Krinkle removed a subscriber: Krinkle.Mar 30 2016, 2:41 AM

Why not simply let transclusion of {{Translatable page}} show the translation page in the current content language of the page where it is transcluded on instead of {{Special:MyLanguage}}? I can't think of a single reason why anyone would want a page with all the translate/tvar tags visible when they transclude. I've also seen several users complain about this behavior so the current behavior of {{Translatable page}} clearly doesn't meet user expectations. Many users also do not know that {{TNT}} can be used to "fix" this so they leave it as it is with the content broken (observed this several times on mediawiki.org).
I propose this:

  • Transcluding {{Translatable page}} on [[New page]] will show the content of [[Translatable page/$lang]] where $lang is the content language of [[New page]]. (eg. transcluding {{Translatable page}} on [[New page/gag]] will show the content of [[Translatable page/gag]]).
  • If [[Translatable page/$lang]] does not exist, fallback to default content language of [[Translatable page]]

Maybe we could introduce a parser function or something like that if we want to show the content in user's interface language but normal transclusions should be in content language, imo.

You are right that could be the most user friendly solution, but I don't see how that could be implemented in the PHP parser and in Parsoid in a clean way.

Nemo_bis added a comment.EditedMay 4 2016, 7:05 AM

Why not simply let transclusion of {{Translatable page}} show the translation page in the current content language of the page where it is transcluded on instead of {{Special:MyLanguage}}?

I don't know about Parser.php and Parsoid, but guillom had implemented a Lua-based solution for this, with a template that had to be applied on the template page itself. The advantage was to avoid updating all template links. The same feature could probably be implemented as some sort of parser function, to be added automatically when one marks a template for translation.

You are right that could be the most user friendly solution, but I don't see how that could be implemented in the PHP parser and in Parsoid in a clean way.

Hmm, I just looked into the Parser code and indeed, this doesn't look like it will be an easy undertaking. Even if we did get something implemented for this, it will probably be very fragile. :/

I don't know about Parser.php and Parsoid, but guillom had implemented a Lua-based solution for this, with a template that had to be applied on the template page itself. The advantage was to avoid updating all template links.

I don't know how we could do it without having a separate subpage for the actual code (which I was hoping we could avoid). That being said, it'd indeed be nice to have TNTN and TNT's functions implemented on Translate.

Nemo_bis updated the task description. (Show Details)Jun 18 2016, 4:13 PM

Can we come up with an intermediate solution to the problem of translatable templates breaking untranslatable pages?

E.g. a simple page like https://www.mediawiki.org/wiki/User:Scott is broken right now because someone localised "Interwiki redirect". It is not clear to me why <translate> can't simply return the default content by default instead of being rendered as literal text.

You are right that could be the most user friendly solution, but I don't see how that could be implemented in the PHP parser and in Parsoid in a clean way.

Hmm, I just looked into the Parser code and indeed, this doesn't look like it will be an easy undertaking. Even if we did get something implemented for this, it will probably be very fragile. :/

You could set a custom template callback? ParserOptions::setTemplateCallback()

E.g. a simple page like https://www.mediawiki.org/wiki/User:Scott is broken right now because someone localised "Interwiki redirect". It is not clear to me why <translate> can't simply return the default content by default instead of being rendered as literal text.

<translate> is not a normal parser tag in the sense that it's not registered as such in Parser due to the nature of how it works. This means that the Parser does not do any normal modifications it does to other extension tags causing it to be visible on page view unless Translate extension processes them on its own.
The reason why this is not normally visible on translatable pages is because Translate currently only does its own parsing and substituting on only these pages before the Parser gets to it by hooking into ParserBeforeStrip.
When templates/pages are transcluded, the Translate's hook handler does not do any parsing on it because the templates haven't been expanded at that point by the parser and Translate does not see any translate tags in the transclusions because they are in the raw {{template}} form.
To workaround this, we have https://www.mediawiki.org/wiki/Template:TNT which automatically transcludes the translation subpage (which contains the text without any translate tags) in the current page's language. Translation admins are generally expected to convert usages of templates when migrating them to page translation system; if it's not done then we have broken pages like the one you mentioned. Also, users not familiar with this system just normally transclude them as usual causing this issue again.

You could set a custom template callback? ParserOptions::setTemplateCallback()

Thanks legoktm. This looks promising. I'll try to see if we can use this to resolve this issue.

Change 307073 had a related patch set uploaded (by Glaisher):
Add ParserFetchTemplate hook

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

Change 307075 had a related patch set uploaded (by Glaisher):
Fetch transclusion text from translation page instead of source page

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

Krinkle removed a subscriber: Krinkle.Aug 30 2016, 1:14 AM
Krinkle added a subscriber: Krinkle.
aaron moved this task from Inbox to Doing on the Performance-Team board.Nov 3 2016, 10:04 PM
ori moved this task from Doing to Radar on the Performance-Team board.Nov 3 2016, 10:05 PM

Change 307073 merged by jenkins-bot:
Add ParserFetchTemplate hook

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

matej_suchanek removed a subscriber: wikibugs-l-list.
Qgil removed a subscriber: Qgil.Nov 24 2016, 8:57 AM

Change 213196 abandoned by Nikerabbit:
[WIP] Allow transclusion with Special:MyLanguage

Reason:
On second thought, maybe some other approach is better in the end.

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

Krinkle removed a subscriber: Krinkle.