Page MenuHomePhabricator

Scribunto: Support :text() in mw.message
Open, Needs TriagePublicFeature

Description

For the moment only rendering by the :plain() method is supported by mw.message.lua, it would be really nice to have a :text() method.

I bumped into this do to lack of {{PLURAL:…}}, and thus has to reimplement similar functionality.

Details

Event Timeline

Izno changed the subtype of this task from "Task" to "Feature Request".Sep 1 2024, 7:40 PM

Change #1075578 had a related patch set uploaded (by BlankEclair; author: BlankEclair):

[mediawiki/extensions/Scribunto@master] mw.message: Add :text() and :escaped()

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

You don’t actually need to reimplement similar functionality: {{PLURAL:…}} is just a normal parser function, so if you run the result of :plain() through frame:preprocess(), it’ll be parsed. You need a frame object for that, which makes it a bit complicated, so I’m not against its direct support in Scribunto, but it’s a probably much simpler workaround for the time being.

Originally there was message:text() but it was removed in T62758. @Jackmcbarn wrote "Message formats other than plain should have never been exposed in this way, as they allow link tables, etc. to be bypassed and serve no useful purpose. This removes them, and also removes title, as it serves no purpose without them."

Change #1075578 abandoned by BlankEclair:

[mediawiki/extensions/Scribunto@master] mw.message: Add :text() and :escaped()

Reason:

Honestly, given the issues raised versus my personal wants, I am not too motivated to solve this issue anymore :p

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

BlankEclair removed a project: Patch-For-Review.
BlankEclair subscribed.

This seems to be possible, per Tim Starling's comment on the patch:

I think :text() could be implemented, but it would have to preprocess using the same Parser instance, not use Message::text() or an equivalent. If I understand correctly, that would address the reasons for its original removal.

...but I'm not gonna be the person doing it