Lucas_Werkmeister_WMDE added a comment.
In T235154#5689460 <https://phabricator.wikimedia.org/T235154#5689460>, @Lucas_Werkmeister_WMDE wrote: > With regard to T235154#5640545 <https://phabricator.wikimedia.org/T235154#5640545>, we decided: > > - We will parse messages PHP-side, before replacing parameters, and add the result (HTML potentially containing `$1`, etc.) to the parser output – most likely in `mw.config` under a name like `dataBridgeMessages` (analogous to `dataBridgeConfig`, but not a part of that). The JS-side code will then substitute the parameters without any further processing (but HTML-escaping them where necessary, of course). > - The init module will load those messages and add them to `mw.messages` (using `mw.messages.set()`), so that they are available to the standard `mw.message()`/`mw.msg()` function and no modification to our `MessagesPlugin` or `MwMessagesRepository` is necessary. So I started writing the messages this, but ran into trouble when they have to link to the repository (which is common in the mockups). To do this directly in the wikitext, the interwiki prefix of the repository would have to be available as a parser function or similar (it can’t be a parameter, because we’re not substituting those in PHP); or the wikitext would have to produce some kind of fake URL that we could replace with the real one, which would be unreliable; or there would be a placeholder for the whole link (`<a>` element), but then we need a “lego message” for the link text, separate from the rest of the message. And it turns out that all of this was based on a false premise. I had assumed that there’s no way to parse wikitext in JS, that we don’t want to implement it, and therefore at some point we have to do the parsing in PHP – similar to what AdvancedSearch does. But as @Pablo-WMDE found out, MediaWiki does in fact support limited wikitext in JS <https://www.mediawiki.org/wiki/Manual:Messages_API#Feature_support_in_JavaScript> – internal (non-interwiki) and external links, a handful of magic words, and a set of whitelisted HTML tags and attributes. This means that, for example, a list is written as `<ul><li>foo</li><li>bar</li></ul>` rather than `* foo\n* bar`, but there are already some messages targeted for that client-side parser that work like this, and so we can probably assume that our translators will be able to cope with this (though we can link to the mw.org documentation in qqq.json, of course). So this seems like the saner way to go: declare a dependency on the `mediawiki.jqueryMsg` module, ship our messages as-is through ResourceLoader (no PHP-side parsing), process them in JS (`mw.message( key, ...params ).parse()`), and take care to only use supported syntax in the English version of the message (HTML tags rather than wikitext syntax). TASK DETAIL https://phabricator.wikimedia.org/T235154 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Lucas_Werkmeister_WMDE Cc: Addshore, Michael, Pablo-WMDE, WMDE-leszek, Lucas_Werkmeister_WMDE, Charlie_WMDE, Aklapper, Lydia_Pintscher, darthmon_wmde, DannyS712, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
