2 * Simple Placeholder-based Localization
4 * Call on a selection of HTML which contains <msg key="message-key" /> elements or elements with
5 * title-msg="message-key" or alt-msg="message-key" attributes. <msg /> elements will be replaced
6 * with localized text, elements with title-msg and alt-msg attributes will receive localized title
10 * <p class="somethingCool">
11 * <msg key="my-message" />
12 * <img src="something.jpg" title-msg="my-title-message" alt-msg="my-alt-message" />
16 * <p class="somethingCool">
18 * <img src="something.jpg" title="My Title Message" alt="My Alt Message" />
22 * Localizes a DOM selection by replacing <msg /> elements with localized text and adding
23 * localized title and alt attributes to elements with title-msg and alt-msg attributes
26 * @param Object: options Map of options
27 * * prefix: Message prefix to use when localizing elements and attributes
29 $.fn
.localize = function( options
) {
30 options
= $.extend( { 'prefix': '' }, options
);
35 .text( mediaWiki
.msg( options
.prefix
+ $(this).attr( 'key' ) ) )
36 .replaceWith( $(this).html() );
39 .find( '[title-msg]' )
42 .attr( 'title', mw
.msg( options
.prefix
+ $(this).attr( 'title-msg' ) ) )
43 .removeAttr( 'title-msg' );
49 .attr( 'alt', mw
.msg( options
.prefix
+ $(this).attr( 'alt-msg' ) ) )
50 .removeAttr( 'alt-msg' );