wikimedia / jquery.i18n

🌐 jQuery based internationalization library
GNU General Public License v2.0
700 stars 143 forks source link

Implement {{int:}} magic word #211

Open lucaswerkmeister opened 4 years ago

lucaswerkmeister commented 4 years ago

I just noticed the {{int:message-key}} magic word isn’t implemented. Is there a particular reason to omit it or was it just not done yet?

Here’s a simple implementation (using modern JS syntax because I’m lazy):

$.extend( $.i18n.parser.emitter, {
    int( nodes ) {
        return $.i18n( ...nodes );
    },
} );

(It doesn’t emit “⧼xyz⧽” for undefined message keys like MediaWiki does, but jquery.i18n doesn’t seem to do that in general, so I’m not sure if its {{int:}} should.)