From Support
Jump to navigation Jump to search


Hi. Please mark Template:Optional for translation.

Shirayuki (talk)12:49, 22 December 2020

I approve; the recent changes did not work at all (the translation being actually in another subtemplate, listed in the documentation). Note: the template itself does not need to be translated, as the translation is actually in the subtemplate listed.

Now I see that with the most recent change, the template itself becomes translatable ; it i using now an "autotranslate" switch that detects when it should show the translated subtemplate directly, or use a "LangSwitch" function in a Lua module to select and render the appropriate translated subtemplate).

Note that I first invented this "trick" years ago, and it has been now more widely reused; it is a bit complex for some authors so it requires some explaination about why it is used and how it works: the trick does not require creating and maintaining another external template, all is done in the source template, and translated subtemplates are generated automatically with all new translations, and translators don't have to worry about the syntax, but only on actual translation items; and transcluding the template remains simple, as if it was not translatable, without changing the syntax; the tricks works with a "#switch: on an empty translation unit, which will be effectively empty on the generated translated templates, but not empty on the base template as it still contains the "translate" markup (opening and closing "translate" tags are eliminated only in a later phase just before the HTML generation, but not during the template expansion) and this allows the correct behavior to occur.

Note that this is still a "trick", which may eventually change and no longer later, provided that the translate extension provides a way to detect if we are on the base source page or in a generated translated subpage (this is not the same as detecting the current page language, which is not testing the template page itself but the target page of the transclusion).

Verdy p (talk)16:44, 22 December 2020

I don't understand why so much effort is put into this template. There are plans to convert this to be a feature of Translate to avoid divergence between configuration and message documentation: https://phabricator.wikimedia.org/T270703

Nike (talk)07:51, 30 December 2020