Page MenuHomePhabricator

Translate tags visible in TextData text in source language embeds
Closed, DuplicatePublic

Description

In the template I have, for example, this:

TextData =
   pos:(255,$title)
   fontsize:XL
   textcolor:black
   text:"<translate><!--T:12--> LibreOffice Release life cycle</translate>"

It renders without <translate> tags in the template view:
https://wiki.documentfoundation.org/Template:LibOReleaseLifecycle
as well as embeds in translated pages:
https://wiki.documentfoundation.org/ReleasePlan/es

However, in the source language page, the <translate> tags are rendered:
https://wiki.documentfoundation.org/ReleasePlan

Event Timeline

Could you explain what the {{#translation:}} part does in {{LibOReleaseLifecycle{{#translation:}}}}? Asking as https://www.mediawiki.org/wiki/Project:Language_policy#Translate_extension states with {{#translation:}} for categories and {{TNT}} for translatable templates. (though that's MediaWiki.org only.)

(Also, there is an unneeded whitespace in <translate><!--T:12--> LibreOffice Release life cycle</translate> between the > and the L.)

Could you explain what the {{#translation:}} part does in {{LibOReleaseLifecycle{{#translation:}}}}? Asking as https://www.mediawiki.org/wiki/Project:Language_policy#Translate_extension states with {{#translation:}} for categories and {{TNT}} for translatable templates. (though that's MediaWiki.org only.)

The {{#translation:}} template appends the language code dynamically per current page. So you will get LibOReleaseLifecycle/es when visiting a Spanish page that uses the EasyTimeline template.

(Also, there is an unneeded whitespace in <translate><!--T:12--> LibreOffice Release life cycle</translate> between the > and the L.)

The whitespace is added by the Translate extension, when one marks a page for translation. There is no way to avoid it.

Nikerabbit added a subscriber: Nikerabbit.

This is a known issue with the Translate extension. See T47096: Add a way to transclude template or other page in the correct language for current work on this.

As a workaround, you need something like Template:TNT on mediawiki.org/meta.wikimedia.org. That uses a Lua module, so it is not easy to just copy over. However the logic is relatively simple to re-implement. Basically you never want to transclude a translatable template directly. In case the source language matches the current language, you want to instead include the "clean" version TranslatableTemplateName/SourceLanguage. Something like the following might work for you:

{{#if: {{#translation:}} | {{#translation:}} | /en }}

Do note that neither this nor your current solution handles the fallback in the case the translation page does not exist.