Page MenuHomePhabricator

Develop a generic stand-alone service that adapts templates across wikis
Open, Needs TriagePublic

Description

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 Turkish, it will post the following structure:

{
    sourcewiki: "enwiki",
    targetwiki: "trwiki",
    template: "{{Verse translation|ਸਹੀ ਰਸਤਾ ਵਖਰੇ ਲੋਕਾਂ ਲਈ ਵਖਰਾ ਹੈ। ਆਪਾਂ ਏਕਤਾ ਵਿਚ ਰਹਿਏ, ਜੈ ਜੈ।|The right way is different for different people. Let us live in union, then we all win, win.|lang=pa|attr1=Tjinder Singh}}"
}

And it will get the following output:

{
    template: "{{Şiir çevirisi|ਸਹੀ ਰਸਤਾ ਵਖਰੇ ਲੋਕਾਂ ਲਈ ਵਖਰਾ ਹੈ। ਆਪਾਂ ਏਕਤਾ ਵਿਚ ਰਹਿਏ, ਜੈ ਜੈ।|The right way is different for different people. Let us live in union, then we all win, win.|dil=pa|atıf1=Tjinder Singh}}"
}

So:

  • The template name Verse translation is translated to Şiir çevirisi. This can be done now using sitelinks.
  • The first two unnamed parameters are the same.
  • The lang parameter is translated to dil.
  • The attr1 parameter is translated to atıf1.

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:

  • It will be possible to copy a template (Ctrl-C) in one wiki and paste it (Ctrl-V) in another wiki in Visual Editor. 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.
  • 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.
  • Content Translation should start using this service instead of its own built-in template adaptation logic.

Event Timeline

Amire80 created this task.Jan 19 2020, 12:02 PM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptJan 19 2020, 12:02 PM
Amire80 updated the task description. (Show Details)Jan 20 2020, 11:35 AM
Amire80 renamed this task from develop a generic stand-alone service that adapts templates across wikis to Develop a generic stand-alone service that adapts templates across wikis.Feb 10 2020, 5:29 PM
Amire80 updated the task description. (Show Details)Feb 13 2020, 11:11 AM