Translatable modules/Current solutions

 The Translatable modules project is trying to build a new framework for module localization.

These are examples of current solutions for storing and showing localized messages in modules and templates, which this document’s author was able to find. There may be other solutions; if you know any, please add them.

A new solution that will be developed in this project has to:
 * Keep the current solutions functional.
 * Have the good features of the current solutions.
 * Add new features that resolve problems with the current solutions.
 * Provide a convenient transition path for developers who want to make the switch.

Lua table 1: Module:I18n on Commons
Module:I18n on Commons loads messages and translations from other modules, named Module:I18n/*, for example Module:I18n/artwork.

Every key points to a list of values indexed by language code. The translations have to be edited in the module’s source code.

Lua table 2: Module:Wikidades/i18n on the Catalan Wikipedia
The Catalan Wikipedia has local modules for displaying infoboxes with rich structured data from Wikidata. They are local, but built in a way that facilitates exporting to other languages. Many of the translatable messages are actually Q item labels that are translated on Wikidata itself, but those that can’t be translated on Wikidata, are translated as Lua tables. Every language is stored in a separate module, for example: The translations have to be edited in the module’s source code. To actually become usable, the package of modules and templates has to be exported to the Wikipedia in the target language.
 * English: w:ca:Module:Wikidades/i18n/en
 * Catalan: w:ca:Module:Wikidades/i18n (no language code)
 * Galician: w:ca:Module:Wikidades/i18n/gl

A somewhat comparable solution can be found at Module:Central on mediawiki.org.

.tab files on Commons
This was developed as part of the Multilingual Templates and Modules volunteer project.

Messages are stored in the .tab files loaded using functions in Module:TNT (not to be confused with Template:TNT).

An advantage of .tab files is that those that are stored on Commons are global: they can be read from Lua code on any wiki. To be usable on wikis other than Commons, the modules’ code has to be copied to that wiki, manually or using the DiBabel bot.

A full list of tab files with translatable messages on Commons can be found at c:Special:PrefixIndex/Data:I18n.

The translations have to be edited in raw .tab files.

Module:ModuleMsg on Meta
The Module:ModuleMsg on Meta implements loading of modules from translatable pages. Messages are added to a translatable page and loaded using the get_msgs function, which uses identifiers from translation unit markers as message keys. Example: meta:Module:Wikimedia Resource Center using messages from meta:Template:I18n/Wikimedia Resource Center.

An advantage of this method is that the familiar Translate interface is already used for preparing the pages and translating them.

More?..
There may be more module localization solutions that the document’s author couldn’t find. Input is welcome!