Page MenuHomePhabricator

Structured localization framework for templates
Open, Needs TriagePublic

Description

Templates that are useful in more than one language need a convenient and uniform localization framework for translating their messages.

This will be needed for templates that are used across wikis when this becomes possible, but already now this is needed for templates that are used on multilingual wikis such as Commons or Wikidata.

At the moment there is no such framework. Templates can now be translated in two ways:

  1. Copy the template code to another wiki, go through its wiki syntax, and change the strings. This is very flexible, but also extremely inefficient because it creates a forked copy and severs the connection to the original template and doesn't allow proper code reuse and collaboration.
  2. Use the TNT system, which is based on the Translate extension's page translation capability. This is more structured and allows proper code sharing, but it has several disadvantages, too:
    • The translations can only be shown in the user's language. Sometimes it is useful to show them in the content language of the page, or a custom selected language. None of this can be done conveniently now.
    • This system only allows the translation of strings that are displayed to the end users. For truly comprehensive localization, it is also necessary to allow structured translation of template parameter names and the template title, which is used for transclusion in pages. (It is possible to translate template and parameter descriptions in TemplateData, which is good, although it could use a few improvements.)
    • The code of the template is quite repetitive and difficult to maintain.

It would be much nicer if templates could be translated the same way extensions are:

  • Having the same underlying algorithmic and page layout code for all the languages, but separate translations.
  • Using a dedicated translation interface so that translators wouldn't have to deal with any code or wiki syntax (probably with the Translate extension).

In addition to the features available for extensions translation, templates also need another important feature: a stable and structured way to translate the title of the template and the names of its parameters so that they would be usable in the language of the wiki. This will only be needed for global, cross-wiki templates, and not for multilingual wikis, but should be planned for as early as possible in the process.

My user-level proposal for how this will be done is described in more detail on the page Global templates/Proposed specification, short version and in even more detail on the page Global templates/Proposed specification. This project also needs technical architecture, which is TBD.

Some steps to making this reality:

  • Some adaptations in the Translate extension: Showing translatable templates in the message group selector, possible integration with TemplateData, etc.
  • Decision on which syntax to use for inserting messages into the template code.
  • Decision on where to store the messages, the message keys (if needed), their translations, and how to customize them per project.
  • Decision on how to store the translations of the template title and parameters.
  • And probably more things.

A truly comprehensive solution will only come around when it will be possible to efficiently share templates and modules across wikis (T6547, T11890, T121470), but some steps towards designing it and making necessary modifications in Translate can possibly be made earlier.

Some good steps towards designing and implementing such a thing were made in T122086: RFC: Sharing templates and modules between wikis - poor man's version (investigation), and a lot of the ideas from that project could be shared with this one.

A similar framework is needed for Scribunto modules, and perhaps some code and ideas for them can be shared, but it's nevertheless distinct. It's tracked at T238417: Structured localization framework for Scribunto modules.

Event Timeline

Amire80 created this task.Nov 15 2019, 3:15 PM
Restricted Application added a project: VisualEditor. · View Herald TranscriptNov 15 2019, 3:15 PM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald Transcript
JTannerWMF moved this task from To Triage to Freezer on the VisualEditor board.Dec 3 2019, 4:43 PM
JTannerWMF added a subscriber: JTannerWMF.

This task is not in scope for the Editing-team at this moment

Partially related patch (5 years old):
https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Scribunto/+/158323/
proposed to move Module:Arguments from enwiki to MediaWiki and adding translation capabilities to getArgs

Partially related patch (5 years old):
https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Scribunto/+/158323/
proposed to move Module:Arguments from enwiki to MediaWiki and adding translation capabilities to getArgs

Thanks! Without looking too deeply into it, but just from the title: isn't it more related to T238417: Structured localization framework for Scribunto modules?

Partially related patch (5 years old):
https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Scribunto/+/158323/
proposed to move Module:Arguments from enwiki to MediaWiki and adding translation capabilities to getArgs

Thanks! Without looking too deeply into it, but just from the title: isn't it more related to T238417: Structured localization framework for Scribunto modules?

Yes. I will place a note there

Vutting renamed this task from Structured localization framework for templates to เทมเพลตservices.Mar 21 2020, 6:19 AM
DannyS712 renamed this task from เทมเพลตservices to Structured localization framework for templates.Mar 21 2020, 6:20 AM
Amire80 updated the task description. (Show Details)Jun 15 2020, 6:44 AM
Amire80 updated the task description. (Show Details)
Amire80 updated the task description. (Show Details)Jun 15 2020, 6:52 AM
Amire80 updated the task description. (Show Details)
He7d3r added a subscriber: He7d3r.Jun 29 2020, 4:02 PM