Page MenuHomePhabricator

Add magic word for translatable unit language
Closed, ResolvedPublic

Description

MediaWiki core has no concept of "context language" on smaller level than of a page. Translate extension can do this, albeit a bit hackily.

When we are processing translatable page, we can easily do some string processing that replaces a marker with the language of the unit (basically, either the target language if translated, or source language if untranslated, assuming no fallback support is added).

This could be named {{UNITLANGUAGE}} or {{TRANSLATIONLANGUAGE}} to be consistent for {{PAGELANGUAGE}}. The downside is, that this would be a simple string replacement, so behavior is not exactly the same as with regular magic words. Maybe it should look completely different altogether?

This would enable using language dependent magic word such as {{FORMATNUM}} and {{#time}} safely, such that they match the language of the text around.

Implementation note: It should be possible to use this magic word in translation variables. E.g. Language: <tvar|lang>{{TRANSLATIONLANGUAGE}}</> should also work.

Affected documentation

Expected outcome

No mismatched localisation of date and numbers, etc. in untranslated translation units.

Event Timeline

Change 603472 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] Add {{TRANSLATIONLANGUAGE}} for translatable pages

https://gerrit.wikimedia.org/r/603472

Nikerabbit updated the task description. (Show Details)

Change 603472 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Add {{TRANSLATIONLANGUAGE}} for translatable pages

https://gerrit.wikimedia.org/r/603472

abi_ subscribed.

Tested this on Mediiawiki

  1. If a unit is translated, the {{TRANSLATIONLANGUAGE}} gets interpolated to the translated language code.
  2. Otherwise it displays the source language.

Pending: Documentation changes.

We can mark this as done after that.

abi_ moved this task from In Review to Done on the Language-Team (Language-2020-July-September) board.

Documentation updated here - https://www.mediawiki.org/wiki/Help:Extension:Translate/Page_translation_administration

Reviewed, and looks good. Resolving this task.