Page MenuHomePhabricator

Support "{{int:}}" (with parameters and auto-dependencies for messages) in jqueryMsg
Open, LowPublicFeature

Description

Background: http://www.mediawiki.org/wiki/Localisation#Messages_quoting_each_other

I have the following message in an i18n file:

'ethereditor-warn-others' => 'Warning: Some other users are currently editing this page in a collaborative session using the EtherEditor extension. While you are welcome to keep editing here, their changes may conflict with yours. Please consider clicking the "{{int:ethereditor-collaborate-button}}" button in the top right of the page screen to join them, and avoid merge conflicts.'

This is a great thing and all, since I don't want people to need to update this message if the ethereditor-collaborate-button message gets changed. OK, good stuff.

However, the JavaScript message object has two huge problems with this:

  1. The JS message object doesn't even glance at the {{int:....}} part, just leaves it.
  2. Even if it did look at it, I never included 'ethereditor-collaborate-button' in the required messages for this module, so there would be exactly no way for the library to sanely handle the int-hack method.

So, possible solutions:

  1. Compile the int-hack bits of the message on the server before it gets sent to the client. This isn't ideal, since the client couldn't modify the message if necessary (for example, I use a message in the same extension to generate a regular expression).
  2. Auto-include the int-hacked messages (in this case, ethereditor-collaborate-button) in the resource loader's loaded messages, and then consider {{int:}} parts of a message while parsing. This would take some doing, but it's possible. Also, a potential problem (and this is perhaps a consideration for the entire l10n system, not just client-side) is that {{int}} is a valid template on some wikis. I'm not sure if that's important, maybe if the parser looks for {{int:<something>}}, there won't be overlap with {{int|something}}.

T49840: Add parameter support to int: magic word in jQueryMsg (merged into this) is adding parameters (part of the PHP parser's int functionality). E.g. {{int:editsectionhint|MediaWiki}} from https://www.mediawiki.org/wiki/Help:Magic_words#Localization


Version: 1.20.x
Severity: enhancement

Details

Reference
bz38381

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:10 AM
bzimport set Reference to bz38381.
bzimport added a subscriber: Unknown Object (MLST).

Interesting, the 2nd solution sounds like the better solution in this case keeping in mind the way messages are loaded and parsed. Also note that the client side parser does support parser functions in general (e.g. it has logic for detecting them, this is used for {{GRAMMAR:}} and {{PLURAL:}}).

Changing to be an 'enhancement' instead of a bug, as the status quo is that that is not supported on the client, so messages intended for client-side use should not contain these in the first case as they were never supported in the past either.

matmarex renamed this task from Support "int-hack" in mediawiki javascript parser to Support "int-hack" in jqueryMsg.Dec 31 2014, 12:07 AM
matmarex set Security to None.
matmarex added a subscriber: Mattflaschen-WMF.

I fixed "The JS message object doesn't even glance at the {{int:....}} part" in T45574: Implement {{int:message}} support in jqueryMsg. To use it, you currently have to specify the message (ethereditor-collaborate-button in your example) in the module's list of messages (even though it's used indirectly).

So the only remaining question is whether to attempt to auto-add messages to the module's message list. This basically means the de facto list of messages varies depending on message content (not sure how much of a pain this would be for cache invalidation).

Note, this is not really a hack AFAICT. This is the intended use of {{int}}. My understanding is int is only considered (by some) a hack when it's used for on-wiki purposes (e.g. file description pages with on-wiki templates).

Mattflaschen-WMF renamed this task from Support "int-hack" in jqueryMsg to Support "{{int:}}" (with parameters and auto-dependencies for messages) in jqueryMsg.Dec 31 2014, 5:06 AM
Mattflaschen-WMF updated the task description. (Show Details)
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:14 AM