MediaWiki:Gadget-fuzzyeverywhere.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* 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]
);
});
}
});