Translatable templates

What’s the best way to create wiki templates where some texts can be translated, but other parts of the template are the same in all language versions? Ideally, it would even be possible that the same text string appears in different templates and only needs to be translated once.

The only acceptable idea I can come up with is this:

  • add a lang parameter to the original template, and include it as e.g. {{OriginalTemplate|lang=de}}

  • create templates for every single piece of text in the original template that will also have a lang parameter and print a text translated to that language

  • use these new templates in the original template and pass the lang parameter to them

But I would need to create a lot of tiny templates for that, and I don’t know whether it would cause performance problems in the wiki. Are there any alternative approaches? Does MediaWiki itself provide any kind of localization support for wiki content?

Well I just know the lang namespaces like DE: CZ: but I have no clue if they will be used on Templates, too :confused:

I’ve also thought about it the last days and I think the easiest way would be to do it like you translate a normal wiki page: add the languages template on the main page (between and ), copy the original template to the language namespace and translate all the strings which should be translated.

The small disadvantage of this method is that you have to use the full template-name including the language-prefix ( {{xx:Template:abc}} ) but you also have to use a language-prefix when you link to a translated page ( [[xx:abc]] ). So this shouldn’t be a big problem. A few days ago I’ve translated the Infobox_small template like that and I’ve also added a redirection (DE:Template:Infobox_small to Template:DE:Infobox_small) because I thought it would be better to have all templates in the same namespace.

Bye, Andreas

There is also the problem that every later change to the template needs to be manually copied to all translations of the template; even if the change doesn’t affect a part of the template which isn’t language-specific. That’s one of the downsides I would have hoped to avoid.

Well, thanks for the ideas anyway, it seems that there simply isn’t a perfect solution.