Initial roll-out of Scribunto library for accessing message bundles
Closed, ResolvedPublic8 Estimated Story Points

Description

We added a Scribunto Lua library in Translate extension (See: T359918)

This would involve deciding how we want to:

  1. Roll out the feature siltently on Meta-Wiki
  2. Discuss the feature with the module authors/maintainers and gather feedback.

Roll-out plan

Note that the feature is not ready for usage with popular templates yet, as the process of handling parser cache expiry is not implemented efficiently. (see: T369894)

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change #1099725 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[operations/mediawiki-config@master] Enable Translate message bundle Scribunto library

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

@abi_ What’s the strategy? This task is about creating a strategy, but you uploaded a (work-in-progress) patch for it without saying anything about the strategy. Also note that the patch would enable it on Meta, which has quite a few popular templates, for example Community Wishlist Survey ones, which could benefit from message bundles – and if you enable the Scribunto library there, you can’t ensure that these templates won’t be migrated to message bundles.

Change #1100822 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] MessageBundleLuaLibrary: Mark feature as experimental

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

Change #1100822 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] MessageBundleLuaLibrary: Mark feature as experimental

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

Here's a tentative rollout plan:

Based on the feedback gathered, we'll proceed further.

In the meantime, it might be worth it to start addressing T369894: Improve parser cache expiry mechanism for message bundle dependents

abi_ renamed this task from Determine release strategy for Scribunto Lua library for message bundle to Determine and execute release strategy for Scribunto Lua library for message bundle.Jan 6 2025, 5:39 PM
abi_ updated the task description. (Show Details)
abi_ changed the point value for this task from 2 to 4.
Nikerabbit renamed this task from Determine and execute release strategy for Scribunto Lua library for message bundle to Initial roll-out of Scribunto library for accessing message bundles.Jan 9 2025, 11:44 AM

Change #1099725 merged by jenkins-bot:

[operations/mediawiki-config@master] Enable Translate message bundle Scribunto library on MetaWiki

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

Mentioned in SAL (#wikimedia-operations) [2025-01-09T14:31:35Z] <lucaswerkmeister-wmde@deploy2002> Started scap sync-world: Backport for [[gerrit:1099725|Enable Translate message bundle Scribunto library on MetaWiki (T379892)]]

Mentioned in SAL (#wikimedia-operations) [2025-01-09T14:38:51Z] <lucaswerkmeister-wmde@deploy2002> abi, lucaswerkmeister-wmde: Backport for [[gerrit:1099725|Enable Translate message bundle Scribunto library on MetaWiki (T379892)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-01-09T15:04:28Z] <lucaswerkmeister-wmde@deploy2002> Finished scap sync-world: Backport for [[gerrit:1099725|Enable Translate message bundle Scribunto library on MetaWiki (T379892)]] (duration: 32m 53s)

Hi @abi_, I'm a bit confused about how this is meant to be used. The lua library being part of the Translate extension means that it's available only on multilingual wikis. There are major modules like Module:Citation/CS1 that are maintained on enwiki and copied all over other wikis. Is there a plan to install the Translate extension more broadly?

This feature loads translations from the wiki it’s used on, with Translate helping creating the translations. This is not appropriate for modules shared across a large number of wikis, as it means that the translations need to be created on each and every wiki separately (which would mean n×m×k pages, where n is the number of wikis, m is the number of (English) messages of the module, and k is the number of languages). Instead, human-readable text of such modules should use Module:TNT, which keeps the translations centrally on Commons (and all messages and languages on a single page), and other aspects of localization (category names, CSS classes etc.) should be in Lua.

Maybe this central translation on Commons (JsonConfig) could get some integration with Translate – although Special:Translate has the disadvantage that every translation is a separate edit, so translating a JSON file with seven units would result in seven edits rather than one, which is not nice in light of T343131

The integration with Module:TNT makes sense.

I wouldn't be concerned about Commons db size as that issue is because of categorylinks, templatelinks, and externallinks – none of which i18n messages or JSON files are likely to contribute much to. However, I am kind of disappointed to see that although a message bundle is a JSON file, translations are saved as separate pages for each key, instead of per-language JSON files. The latter format is more effective for using messages outside of a Lua context, for example, in gadgets or user scripts, and even in Lua itself when using mw.loadJsonData(). Also, it's likely to be more performant (single db call to get all messages) and better mimics the i18n of MediaWiki core/extensions.

Nikerabbit changed the task status from Open to In Progress.Jan 13 2025, 8:44 AM
Nikerabbit updated the task description. (Show Details)

I am kind of disappointed to see that although a message bundle is a JSON file, translations are saved as separate pages for each key, instead of per-language JSON files. The latter format is more effective for using messages outside of a Lua context, for example, in gadgets or user scripts, and even in Lua itself when using mw.loadJsonData(). Also, it's likely to be more performant (single db call to get all messages)

This is actually a good idea, although I don’t know if it isn’t too late (given that message bundles have been around for quite some time, only the Lua support is new). If it isn’t too late, it could also help with T369894: Improve parser cache expiry mechanism for message bundle dependents: if there’s only one page per language, we could add a template link to that page (and to fallback languages in case they’re used, which is still not that many) without overfilling the templatelinks table, and we wouldn’t have to care about manually clearing the parser cache.

I guess the Translations: namespace was invented because the extension is only able to render the page from the translation units, not to extract the translation units from the rendered page. In case of JSON, however, it’s trivial to extract the units from the rendered page, so the extra Translations: pages aren’t necessary.

and better mimics the i18n of MediaWiki core/extensions.

While I agree with your idea, I don’t agree with this point of your reasoning: from an on-wiki viewpoint, core/extension is a number of MediaWiki:-namespace pages, one for each message, so the current implementation is closer to that (which could also explain why the current implementation is what it is, in addition to the problems with translatable pages I described above).

QA being done by Amir

QA being done by Amir

A little update:

I'm doing some testing. It looks mostly OK. I've reported T385194, which seemed quite important. A fix for it is merged, but will probably be deployed to Meta only next week, and I'll want to verify it in production before further communication.

I found a few more issues, and I'll report them, but none of them seem critical.

I'm also improving the documentation so that there will be clear instructions for module writers and translators.

I reached out to a developer of one module, and showed a demo of how can a module be rewritten with the new Translatable module feature: https://meta.wikimedia.org/w/index.php?title=User_talk:CalendulaAsteraceae&oldid=28340327#Translatable_module

The response has been quite positive :)

This task, as it is written, can probably be closed: the feature is deployed and tested, and initial communication is done. There is more to do as follow-ups, but this part is done. Thanks to everyone!

Nikerabbit subscribed.

Leaving open until we decide if we want to announce this in some way or not.

You should at least send a Tech News announcement IMO.

We'll review the documentation readiness and then announce it (probably tech news).

We'll review the documentation readiness and then announce it (probably tech news).

We are currently reviewing the documentation and evaluating whether we want module authors to widely adopt this library. Additionally, we are considering whether any guidelines should be established. We will make an announcement once these decisions have been finalized.

Pending:

  • Get documentation reviewed: www.mediawiki.org/wiki/Help:Extension:Translate/Message_Bundles/Lua_reference - @abi_
  • Prepare communication message - @UOzurumba
  • Prepare video demonstrating the use of the library - @Amire80
  • Update a small module on Meta-Wiki to use the new Lua Library - @Amire80

We're planning to reach out to the community for feedback before the end of this week.

abi_ set Due Date to Jul 24 2025, 6:30 PM.Jul 21 2025, 1:25 PM
abi_ changed the point value for this task from 4 to 8.Jul 24 2025, 1:18 PM

Updating SP to reflect the amount of work done.

Pending:

  • Get documentation reviewed: www.mediawiki.org/wiki/Help:Extension:Translate/Message_Bundles/Lua_reference - @abi_
  • Prepare communication message - @UOzurumba
  • Prepare video demonstrating the use of the library - @Amire80
  • Update a small module on Meta-Wiki to use the new Lua Library - @Amire80

We're planning to reach out to the community for feedback before the end of this week.

All of these are done. The communication is written, but not yet distributed.

The most significant issue I encountered while preparing the examples for the video: T400578

....

All of these are done. The communication is written, but not yet distributed.

Thanks I've updated the message.

Lets do a quick review of the communication and roll it out.

Quiddity subscribed.

Sorry for the workboard noise, I got confused about the overlap between this task and T359918: Lua interface for convenient access to translations in a message bundle, which I now believe is distinct from this. I'll await the draft entry (for Tech News) for this task, or further corrections if I'm still misunderstanding something. Thanks.

There is only one Scribunto/Lua interface in Translate, both tasks are about this single feature (even if they confusingly have distinct relation graphs…). I think the tag would have a better place here, since that task hasn’t seen activity basically since November; the config change connected to it is about the release on testwiki; the Meta one is here.

abi_ moved this task from Need QA to Done on the LPL Essential (2025 Jul-Oct) board.

The communication roll out is complete. Gathering and responding to feedback is outside the scope of this task.