Many templates have similar functionality in different wikis. There are several tasks and proposals to make the storage of such templates fully global: T52329, T66474, T6547, T121470, Global templates, etc.
Another thing could be done, whether the templates are fully global or not: A generic stand-alone service that adapts templates across wikis.
If templates are truly global, it will be easier to build such a thing. Indeed, such a service will be necessary for global templates to be effective. However, it's possible to make such a thing already now, while templates are not yet global. The Content Translation extension is currently able to adapt templates between languages, mostly by using Wikidata sitelinks, parameter names, and TemplateData aliases. This logic from Content Translation could be made autonomous and stand-alone, as a step to a full independent service of this kind.
Here's a simplistic example of how it will work. To adapt a transclusion of the Verse translation template with some content from English to Portuguese, it will post the following structure:
{ sourcewiki: "enwiki", targetwiki: "ptwiki", template: "{{Cite encyclopedia|title=Lin Shu|year=1852|encyclopedia=Encyclopedia Translationica|publisher=Hundred Rivers Publishing House|location=Baichuan}}" }
And it will get the following output:
{ template: "{{Citar enciclopédia|titulo=Lin Shu|ano=1852|enciclopédia=Encyclopedia Translationica|publicado=Hundred Rivers Publishing House|local=Baichuan}}" }
So:
- The template name Cite encyclopedia is translated to Citar enciclopédia. This can be done now using sitelinks.
- The parameters are translated:
- title ➡️ titulo
- year ➡️ ano
- encyclopedia ➡️ enciclopédia
- publisher ➡️ publicado
- location ➡️ local
The parameter names can currently be mapped using TemplateData aliases. It's not perfect, but it works for Content Translation. It should become more structured in the Global templates age.
The parameter values are not translated in this example, and this shouldn't be a requirement for the first version of this service. Perhaps this can be added as a feature further down the road. The initial scope for this feature is just about translating the template title and parameter names as quickly and reliably as possible, without having to look them up manually in documentation.
If there is a nested template in the parameter value, the service should probably attempt to adapt it recursively, at least by default.
Having such a service independently of Content Translation will allow easier template handling in more contexts where it is useful. For example:
Visual Editor: It will be possible to copy a template (Ctrl-C) in one wiki and paste it (Ctrl-V) in another wiki . If the templates are properly mapped to each other, it will just work. Of course, the editor will probably have to change the parameter values, but the step of looking up the parameter names will disappear, which will be a significant improvement. This will probably also work in the 2017 wiki text editor.
2017 wikitext editor: It can probably be like in the Visual editor (see previous point), because it can do automatic transformations of wiki syntax.
Classic wikitext editor: It will be possible to have a stand-alone tool or a dialog box in the wiki text editor where the user will post the source template, indicate the source and the target languages, push a button, and get wiki text that can be pasted. Here's a mockup of how it can look like:
Step one: While editing an article, press an "Adapt template" button in the toolbar, and get this window:
Step two: Copy the template wikitext from another wiki. Select the language from which you copied. Paste it to the top textarea. After a few seconds, the bottom textarea shows the adapted template. Click "Insert" to add it:
Nothing will change in the frontend user interface of Content Translation. Internally, it will switch to using this service instead of using its own built-in template adaptation logic.
(In these mockups above, the adaptation is from English to Portuguese, as in the task description. The user interface is in English for easier understanding by everyone, but in reality the user interface will be in the language of the current wiki, in this case Portuguese.)
Here's a very high-level flowchart for the whole thing: