At Wikimania 2016 I met @Blahma, who showed me Lua modules that he wrote to adapt templates between languages. It can easily solve some of the template adaptation issues that we have in CX in a scalable way—it will put most of the parameter adaptation work in the hands of the editor communities.
I tested it in the Czech and the Hebrew Wikipedias, and it works.
The way in which it works is this:
- It has the main Lua module. In cs.wikipedia it's https://cs.wikipedia.org/wiki/Modul:TemplateTranslation . It implements the generic template adaptation code, which works for all templates. It adapts templates from other modules into Czech (cs).
- For every source language there is a module in a subpage with the source language code, for example, for Slovak it's https://cs.wikipedia.org/wiki/Modul:TemplateTranslation/sk. It defines a list of templates that can be adapted.
- For every template there is a module in a subpage, such as https://cs.wikipedia.org/wiki/Modul:TemplateTranslation/sk/Infobox_Slovensk%C3%A1_obec . "Infobox Slovenská obec" is the name of the template in the source language, and this module defines the name of the target language template ("Infobox - sídlo světa"), and maps between the parameters. The mapping can be simple, just copying the values (o['jméno'] = i['Názov']), and it can also do other transformation if needed (o['název celku 3'] = '[[' .. i['Región'] .. ']]').
- The module is invoked by writing: `{{#invoke:TemplateTranslation/sk|Infobox Slovenská obec|` ... and then all the arguments are copied from the source template.
Invoking the module creates a template that is adapted to the target language. It can also be invoked as {{subst:#invoke....
What we can do in CX is the following:
- When encountering a template (e.g. {{Cite web|param1 = value1|param2 = value2}}) in the source language (e.g. "en") check whether the target language has [[Module:TemplateTranslation/en/Cite web]].
- If it exists, insert {{subst:#invoke:TemplateTranslation/en|Cite web|param1 = value1|param2 = value2}} to the translation.
We can also move the json template adaptation files that we currently have to this, and let the communities maintain them.