Shamelessly looking at dialog code to lift, I came across WikiLove's dialog box: $dialog = $( '\ <div id="mw-wikilove-dialog">\ <h2><html:msg key="wikilove-get-started-header"/></h2> ...
Wait, html:msg ? It calls $dialog.localize() and the whole chunk of DOM gets localized at once.
This has been in core since I believe 1.17, and the AFT, MoodBar, and WikiLove extensions use it. I'm not sure why it's not mentioned in Localisation https://www.mediawiki.org/wiki/Localisation or Manual:Messages API https://www.mediawiki.org/wiki/Manual:Messages_API . I just added it to Resource Loader modules pagehttps://www.mediawiki.org/wiki/ResourceLoader/Default_modules#jquery.localize .
Why isn't newer code using it, did it fall out of favor? E.g. Echo uses jQuery chaining: $( '<a>' ).attr(...).text( mw.msg( 'echo-overlay-link' ) ). ...
jquery.localize() doesn't give you the control of mw.msg().escape/parse/plain/text() , but for big basic chunks of HTML it seems ideal.
Thanks for any insight, -- =S Page software engineer on E3
I imagine that mw.msg provides more features, such as plural and gender, and that makes it closer to the server-side i18n, but Niklas may know better.
In any case, if it's deprecated, it should be documented.
-- Amir Elisha Aharoni · אָמִיר אֱלִישָׁע אַהֲרוֹנִי http://aharoni.wordpress.com “We're living in pieces, I want to live in peace.” – T. Moore
2013/8/8 S Page spage@wikimedia.org:
Shamelessly looking at dialog code to lift, I came across WikiLove's dialog box: $dialog = $( '\
<div id="mw-wikilove-dialog">\ <h2><html:msg key="wikilove-get-started-header"/></h2> ...
Wait, html:msg ? It calls $dialog.localize() and the whole chunk of DOM gets localized at once.
This has been in core since I believe 1.17, and the AFT, MoodBar, and WikiLove extensions use it. I'm not sure why it's not mentioned in Localisation or Manual:Messages API . I just added it to Resource Loader modules page.
Why isn't newer code using it, did it fall out of favor? E.g. Echo uses jQuery chaining: $( '<a>' ).attr(...).text( mw.msg( 'echo-overlay-link' ) ). ...
jquery.localize() doesn't give you the control of mw.msg().escape/parse/plain/text() , but for big basic chunks of HTML it seems ideal.
Thanks for any insight,
=S Page software engineer on E3
Mediawiki-i18n mailing list Mediawiki-i18n@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-i18n
On 08/17/2013 10:28 AM, Amir E. Aharoni wrote:
I imagine that mw.msg provides more features, such as plural and gender, and that makes it closer to the server-side i18n, but Niklas may know better.
In any case, if it's deprecated, it should be documented.
Despite the misleading name, jquery.localize is MediaWiki-specific. It has a hard-dependency on mw.msg. Since it uses msg rather than message, I believe means it always uses .text() (the default format of mw.msg), but it should pick up jqueryMsg if present.
See https://git.wikimedia.org/blob/mediawiki%2Fcore.git/2305e760f7de7d3053ab310f...
I like the idea of jquery.localize, but I haven't used it in practice.
Matt Flaschen
mediawiki-i18n@lists.wikimedia.org