Page MenuHomePhabricator

{{TRANSLATIONLANGUAGE}} should fallback to {{PAGELANGUAGE}} outside translation units
Open, LowPublicFeature

Description

Feature summary:
I would like to use {{TRANSLATIONLANGUAGE}} in templates, so the template work both inside and outside translation units.
Outside translation units, it should return the same value than {{PAGELANGUAGE}}

Use case(s):
meta:Template:DateT displays a translated date in page language. If we use it inside a translation unit, that creates language inconsistency while the unit is not translated yet (date in translated language, remaining unit text in source language).

Benefits:
The {{TRANSLATIONLANGUAGE}} would work everywhere, the text language would remain consistent with explicit HTML lang attribute keeping the page accessible for screen readers.

Event Timeline

The easy workaround is to locally create a {{TRANSLATIONLANGUAGE}} template which returns {{PAGELANGUAGE}}.

{{TRANSLATIONLANGUAGE}} is not a real magic word. It is replaced by the translation unit language when the wikitext of the translation page is generated. If you place it in Template:DateT, it won’t be able to access the language of the translation unit even if it’s transcluded in one. Unfortunately, those four-parameter {{Date}} transclusions will have to remain. (See for example Community Wishlist Survey/Updates/sv#8 augusti 2023: Wish Updates: this is an untranslated translation unit, yet the date is in Swedish, because the template gets used, not the magic word-like thing.)

I don’t think it’s possible at all to access the translation unit language from a template transcluded in it, as templates don’t know anything about the context they’re transcluded in, only about their parameters and page-level metadata of the page the user is looking at (which may not be the page they’re directly transcluded in, in case of multi-level transclusion).