MediaWiki:Gadget-fuzzyeverywhere.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
This user script seems to have a documentation page at MediaWiki:Gadget-fuzzyeverywhere. |
/**
* Show when fuzzy translations have been included in a template
*
* Fuzzy translations are normally marked with a pink background, but this
* is not shown when they are transcluded from a template.
* Workaround for https://phabricator.wikimedia.org/T287330
*
* @maintainer AntiCompositeNumber
*/
mw.hook( 'wikipage.content' ).add( function ( $content ) {
if (
$content.find( '.mw-translate-fuzzy' ).length &&
// registered means not loaded
mw.loader.getState( 'ext.translate' ) == "registered"
) {
$.when( mw.loader.using( [ 'ext.translate', 'mediawiki.api' ] ) )
// Re-create "Outdated translations look like this message"
.then( function () {
// ext.translate does not include the message we need
return new mw.Api().loadMessagesIfMissing(
['tpt-translation-intro-fuzzy']
);
})
.then( function () {
$( '<div>', {
"class": "mw-pt-translate-header",
lang: mw.config.get( "wgUserLanguage" ),
dir: "auto"
})
.wrapInner( $( '<span>', {
text: mw.msg( 'tpt-translation-intro-fuzzy' ),
"class": "mw-translate-fuzzy"
}))
.insertBefore(
$content.find( '.mw-parser-output' )[0]
);
});
}
});